[esnacc-dev] [PATCH] compiler/core/snacc: Support optional sequences with asnextension
Aaron Conole
aconole at bytheb.org
Wed Jul 6 19:49:17 UTC 2016
From: Hanspeter Halle <hphalle at t-online.de>
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.
Signed-off-by: Hanspeter Halle <hphalle at t-online.de>
Signed-off-by: Aaron Conole <aconole at bytheb.org>
---
compiler/core/snacc-util.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/compiler/core/snacc-util.c b/compiler/core/snacc-util.c
index 05c456e..b4441a4 100644
--- a/compiler/core/snacc-util.c
+++ b/compiler/core/snacc-util.c
@@ -1436,10 +1436,9 @@ IsTailOptional PARAMS ((e),
return TRUE;
retVal = TRUE;
- FOR_REST_LIST_ELMT (elmt, e)
- {
- if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL))
- {
+ FOR_REST_LIST_ELMT (elmt, e) {
+ if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL) &&
+ (!elmt->type->extensionAddition)) {
retVal = FALSE;
break;
}
@@ -1481,10 +1480,9 @@ NextIsTailOptional PARAMS ((e),
SET_CURR_LIST_NODE (e, tmp2);
retVal = TRUE;
- FOR_REST_LIST_ELMT (elmt, e)
- {
- if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL))
- {
+ FOR_REST_LIST_ELMT (elmt, e) {
+ if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL) &&
+ (!elmt->type->extensionAddition)) {
retVal = FALSE;
break;
}
@@ -1513,10 +1511,9 @@ AllElmtsOptional PARAMS ((e),
SET_CURR_LIST_NODE (e, FIRST_LIST_NODE (e));
retVal = TRUE;
- FOR_REST_LIST_ELMT (elmt, e)
- {
- if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL))
- {
+ FOR_REST_LIST_ELMT (elmt, e) {
+ if ((!elmt->type->optional) && (elmt->type->defaultVal == NULL) &&
+ (!elmt->type->extensionAddition)) {
retVal = FALSE;
break;
}
--
2.5.5
More information about the dev
mailing list