troglobit / mini-snmpd

A minimal SNMP agent implementation
https://troglobit.com/projects/mini-snmpd/
GNU General Public License v2.0
69 stars 36 forks source link

Prepend zero-byte before unsigned integers #9

Closed prauscher closed 7 years ago

prauscher commented 7 years ago

As written in #8, currently a unsigned value of 33000 will be encoded as 0x80e8. As Counter32 (and other unsigned types) are treated as regular Integers in X.690 (and most implementations), they will assume a two's complement and decode -32536, resulting in utterly behavior. This pull request resolves this by prepending a zero-byte if the first bit of the unsigned integer is a 1 and therefore could be seen as two's complement.