[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Decoding errors in sequences with only OPTIONAL and extension
Hi all,
we discovered a decoding error when getting an empty sequence for a sequence
definition consisting of only optional elements and an extension marker. In
this case the decoder tries to read the first tag even if the sequence length
is zero. An example ASN1 definition would be:
Aa ::= SEQUENCE {
bb SEQUENCE {
cc OCTET STRING OPTIONAL,
dd INTEGER OPTIONAL,
...
}
}
The generated decoder starts with
void AaSeq::BDecContent (const AsnBuf &_b, AsnTag /*tag0*/, AsnLen elmtLen0,
AsnLen &bytesDecoded)
{
FUNC(" AaSeq::BDecContent");
Clear();
AsnTag tag1 = AsnTag();
AsnLen seqBytesDecoded = 0;
AsnLen elmtLen1 = 0;
tag1 = BDecTag (_b, seqBytesDecoded);
...
which is obviously wrong.
Debugging the compiler I found that the functions IsTailOptional,
NextIsTailOptional and AllElmtsOptional do not take extension elements as
optional, what they are in any cases I can think of. So I fixed the error
with the following patch
--- compiler/core/snacc-util.c.org 2004-04-06 17:13:41.000000000 +0200
+++ compiler/core/snacc-util.c 2007-10-30 15:01:52.000000000 +0100
@@ -1438,7 +1438,7 @@
retVal = TRUE;
FOR_REST_LIST_ELMT (elmt, e)
{
- if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL))
+ if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL) &&
(!elmt->type->extensionAddition))
{
retVal = FALSE;
break;
@@ -1483,7 +1483,7 @@
retVal = TRUE;
FOR_REST_LIST_ELMT (elmt, e)
{
- if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL))
+ if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL) &&
(!elmt->type->extensionAddition))
{
retVal = FALSE;
break;
@@ -1515,7 +1515,7 @@
retVal = TRUE;
FOR_REST_LIST_ELMT (elmt, e)
{
- if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL))
+ if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL) &&
(!elmt->type->extensionAddition))
{
retVal = FALSE;
break;
It would be nice if somebody could validate the patch and include it into the
next release.
Regards
Hanspeter