Commit bf70e374 authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Fix the problem that user supplied value not used in APER

For the following examplified ASN.1,

  TEST DEFINITIONS AUTOMATIC TAGS ::=
  BEGIN

  S1 ::= SEQUENCE  {
    fn INTEGER,
    fb BIT STRING DEFAULT 'A5'H,
    fc OCTET STRING DEFAULT 'FFAABB'H
  }

  END

and input XER as :

  <S1>
    <fn>9845</fn>
    <fc>DEAD9</fc>
  </S1>

The encoded APER should be :

  S1 ::= {
    fn: 9845
    fb: A5
    fc: DE AD 90
  }

but current output is

  S1 ::= {
    fn: 9845
    fb: A5
    fc: FF AA BB
  }

The reason is in SEQUENCE_encode_aper(), default_value_cmp() are
incorrectly checked against 1.

If the input value is equal to default value, this return value from
compare function is 0.
parent fa5a147e
...@@ -1835,7 +1835,7 @@ SEQUENCE_encode_aper(const asn_TYPE_descriptor_t *td, ...@@ -1835,7 +1835,7 @@ SEQUENCE_encode_aper(const asn_TYPE_descriptor_t *td,
/* Eliminate default values */ /* Eliminate default values */
if(present && elm->default_value_cmp if(present && elm->default_value_cmp
&& elm->default_value_cmp(memb_ptr2) == 1) && elm->default_value_cmp(memb_ptr2) == 0)
present = 0; present = 0;
ASN_DEBUG("Element %s %s %s->%s is %s", ASN_DEBUG("Element %s %s %s->%s is %s",
...@@ -1881,7 +1881,7 @@ SEQUENCE_encode_aper(const asn_TYPE_descriptor_t *td, ...@@ -1881,7 +1881,7 @@ SEQUENCE_encode_aper(const asn_TYPE_descriptor_t *td,
} }
/* Eliminate default values */ /* Eliminate default values */
if(elm->default_value_cmp && elm->default_value_cmp(memb_ptr2) == 1) if(elm->default_value_cmp && elm->default_value_cmp(memb_ptr2) == 0)
continue; continue;
ASN_DEBUG("Encoding %s->%s", td->name, elm->name); ASN_DEBUG("Encoding %s->%s", td->name, elm->name);
......
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