diff --git a/libasn1fix/asn1fix_bitstring.c b/libasn1fix/asn1fix_bitstring.c index e2f2434a..f3d5ad73 100644 --- a/libasn1fix/asn1fix_bitstring.c +++ b/libasn1fix/asn1fix_bitstring.c @@ -55,6 +55,25 @@ asn1f_fix_bit_string_type(arg_t *arg) { "is not an identifier", v->_lineno); return -1; } + + /* 21.1 */ + if(v->value == NULL) { + FATAL("BIT STRING NamedBit value at line %d " + "must be explicitly specified in braces", + v->_lineno); + return -1; + } else if(v->value->type == ATV_REFERENCED) { + /* Resolve the value */ + if(asn1f_value_resolve(arg, v, 0)) + return -1; + } + if(v->value->type != ATV_INTEGER + || v->value->value.v_integer < 0) { + FATAL("BIT STRING NamedBit value at line %d: " + "non-negative integer value expected", + v->_lineno); + return -1; + } } return r_value; diff --git a/tests/114-bit-string-SE.asn1 b/tests/114-bit-string-SE.asn1 new file mode 100644 index 00000000..5006b067 --- /dev/null +++ b/tests/114-bit-string-SE.asn1 @@ -0,0 +1,16 @@ + +-- SE: Semantic error + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .114 + +ModuleBitStringNegativeInteger + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 114 } + DEFINITIONS ::= +BEGIN + + T ::= BIT STRING { one(-2) } + +END