Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#45 INTEGER_enode_uper() not working for 32 bit range integers

None
closed-fixed
nobody
5
2014-08-26
2007-12-12
Anonymous
No

With trunk/rev 1405 (-fnative-types NOT set)
I tried this definition of an 32 bit unsigned int:

SequenceNumber ::= [PRIVATE 4] IMPLICIT INTEGER (0..4294967295)

Despite the workaround in INTEGER_encoded_uper():

if(ct->range_bits == 32) {
/* TODO: extend to >32 bits */
long v = value - ct->lower_bound;
if(per_put_few_bits(po, v >> 1, 31)
|| per_put_few_bits(po, v, 1))
_ASN_ENCODE_FAILED;
} else {

the encoded PER cannot be decoded.

SequenceNumber ::= [PRIVATE 4] IMPLICIT INTEGER (0..2147483647)

...,that is range 31 bits, but this did not work either!

So I changed the workaround in INTEGER_encoded_uper():

if(ct->range_bits == 32) {
/* TODO: extend to >32 bits */
long v = value - ct->lower_bound;
if(per_put_few_bits(po, v >> 16, 16)
|| per_put_few_bits(po, v, 16))
_ASN_ENCODE_FAILED;
} else {

...,that is, split the 32 bits into 16 + 16 instead of 31 + 1. This seems to work for the 32 bit range int - the encoded PDU is correctly.

So there seems to be a bug in per_put_few_bits()?

/Matthias

matthias.bolz AT siemens DOT com

Discussion

  • Lev Walkin
    Lev Walkin
    2013-03-24

    • status: open --> closed-fixed
    • milestone: -->