mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
98 stars 71 forks source link

Fix APER length encoding edge case #91

Closed gniemirowski closed 2 years ago

gniemirowski commented 2 years ago

Fix for issue #62 Based on https://github.com/open5gs/open5gs/commit/f47f65a51cae51c0c1b5c2268f2f2f52b162913b

mouse07410 commented 2 years ago

Thanks, @gniemirowski

laf0rge commented 2 years ago

This commit is actually wrong. It doesn't fix the case, but it breaks the corner cases. It should be reverted!

Section 4 of X.691 defines 64K as 65536, and Section 11.5.7 explicitly states c) "range" is greater than 256 and less than or equal to 64K (the two-octet case).

So after this commit, you changing from less-than-or-equal 65536 to less-than 65536, resulting in all non-negative whole numbers with a range of 65536 to be encoded the wrong way (more than two octets)

pespin commented 2 years ago

Related PR containing fixes: https://github.com/mouse07410/asn1c/pull/93

grzegorzniemirowski commented 2 years ago

@laf0rge This commit was about length and not non-negative whole numbers in general. Small lenghts with large ranges (>=64K) should be encoded in single byte. #93 breaks it again.

mouse07410 commented 2 years ago

First, it would be easier to track if this discussion was happening in a new issue, rather than in a merged and closed PR. Would one of you like to open a new issue, or should I do that?

pespin commented 2 years ago

I created this ticket to follow up on this issue: https://github.com/mouse07410/asn1c/issues/94