Menu

#648 Library parses 64 bit unsigned integers incorrectly

perl
invalid
nobody
library (262)
5
2018-03-31
2003-01-21
Anonymous
No

Library version: 4.2.1

Testing found that certain values seem to be parsed
incorrectly. Code inspection found that 64 bit
counters are always parsed as signed integers. The
specification defines this value as an unsigned
integer. I have attached what should be a fix, based
on our testing.

Matthias

________________________________________________________________________________________________________
Matthias David Siebler
Software Developer
Sockeye Networks

[mds] diff snmplib/asn1.c
1492a1493,1496
> if (*bufp & 0x80) {
> low = ~low; /* integer is negative */
> high = ~high;
> }
[mds]

Discussion

  • Dave Shield

    Dave Shield - 2003-02-11

    Logged In: YES
    user_id=88893

    Hmmm....
    I'm not convinced that this patch is correct.
    Yes - Counters *should* take non-negative values,
    but they're encoded as BER INTEGERs, which
    are inherently signed.
    So if the parsing library receives a negative
    integer when it's expecting a counter, I don't think
    that simply ignoring this sign bit is correct.

    At the very least, we should print some form of
    debugging statement. And I'm tempted to say that
    it should perhaps even reject this as a parsing error.
    (in both asn_parse_unsigned_int and a_p_u_int64)

    What does anyone else think?

    [Sent to mailing list as well]

     
  • Bill Fenner

    Bill Fenner - 2018-03-31
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,3 @@
    -
     Library version: 4.2.1
    
     Testing found that certain values seem to be parsed
    
    • status: open --> invalid
    • Group: --> perl
     
  • Bill Fenner

    Bill Fenner - 2018-03-31

    This is a common confusion: the asn.1 serialization for a 64-bit unsigned value 0x8000000000000000 is the 9 bytes 0x008000000000000000.

     

Log in to post a comment.

MongoDB Logo MongoDB