-
-
Notifications
You must be signed in to change notification settings - Fork 114
Description
We have been doing some testing with asn1tools, and ran into an odd bug. It appears that if you define a SEQUENCE OF field which is fixed length and greater than 255, the generated OER C decoder cannot decode the field. Example:
MyMessage SEQUENCE ::= {
someArray SEQUENCE (SIZE(512)) OF Int8
}
If I generate an oer decoder for that, the C code ends up with something like this:
number_of_length_bytes_1 = decoder_read_uint8(decoder_p);
length = decoder_read_uint8(decoder_p);
if ((number_of_length_bytes_1 != 1u) || (length > 0u)) {
decoder_abort(decoder_p, EBADLENGTH);
return;
}Since the size of the sequence, 512, does not fit in one byte, number_of_length_bytes_1 ends up as 2. So, decoding fails.
I apologize if I've just missed something and this is expected behavior, but it seems like a potential issue (especially since the encoder doesn't complain about the length at all). So, I figured I'd report it. For the time being, we worked around the issue by using variable length sequences (e.g. someArray SEQUENCE (SIZE(0..512)) OF Int8), which do not seem to have this issue.