mouse07410 / asn1c

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

fix issue #126: decoding extensible CHOICE error #127

Closed tangzhikun closed 1 year ago

tangzhikun commented 1 year ago

The constraints ct was not effective for extensible CHOICE, so if ct && ct->flags & APC_EXTENSIBLE was true, ct was set to 0.

if(ct && ct->flags & APC_EXTENSIBLE) {
    value = per_get_few_bits(pd, 1);
    if(value < 0) ASN__DECODE_STARVED;
    if(value) ct = 0;  /* Not restricted */
}

Using normal CHOICE constraint in decoding extensible CHOICE was weird. We should change the normal CHOICE constraint to extensible CHOICE constraint when decoding extensible CHOICE, the extensible CHOICE constraint was lb=0,ub=specs->tag2el_count - specs->ext_start - 1. So the conditional structure should be if specs && specs->tag2el_count > specs->ext_start, then decoding the CHOICE which range was specs->tag2el_count - specs->ext_start, and add specs->ext_start to value in the last.

mouse07410 commented 1 year ago

Thank you!