Commit fc23d52b authored by tangzhikun's avatar tangzhikun

fix issue #126: decoding extensible CHOICE error

    The constraints ct was not effective for extensible CHOICE, so if ct && ct->flags & APC_EXTENSIBLE was true,
    ct was set to 0. 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.
parent ebed802c
......@@ -53,8 +53,8 @@ CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
if(specs->ext_start == -1)
ASN__DECODE_FAILED;
if (ct && ct->upper_bound >= ct->lower_bound) {
value = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound + 1);
if(specs && specs->tag2el_count > specs->ext_start) {
value = aper_get_nsnnwn(pd, specs->tag2el_count - specs->ext_start); /* extension elements range */
if(value < 0) ASN__DECODE_STARVED;
value += specs->ext_start;
if((unsigned)value >= td->elements_count)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment