Fixed decoding of negative integers in snmp_asn1_dec_s32t(), removed EXPERIMENTAL status.

This commit is contained in:
christiaans 2006-10-13 11:59:45 +00:00
parent b5f4672155
commit f6f6f11838

View File

@ -1,6 +1,6 @@
/** /**
* @file * @file
* [EXPERIMENTAL] Abstract Syntax Notation One (ISO 8824, 8825) decoding * Abstract Syntax Notation One (ISO 8824, 8825) decoding
* *
* @todo not optimised (yet), favor correctness over speed, favor speed over size * @todo not optimised (yet), favor correctness over speed, favor speed over size
*/ */
@ -333,6 +333,7 @@ snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value)
{ {
u16_t plen, base; u16_t plen, base;
u8_t *msg_ptr; u8_t *msg_ptr;
u8_t *lsb_ptr = (u8_t*)value;
u8_t sign; u8_t sign;
plen = 0; plen = 0;
@ -364,11 +365,11 @@ snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value)
len--; len--;
if (sign) if (sign)
{ {
*value &= *msg_ptr; *lsb_ptr &= *msg_ptr;
} }
else else
{ {
*value |= *msg_ptr; *lsb_ptr |= *msg_ptr;
} }
*value <<= 8; *value <<= 8;
ofs += 1; ofs += 1;
@ -388,11 +389,11 @@ snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value)
} }
if (sign) if (sign)
{ {
*value &= *msg_ptr; *lsb_ptr &= *msg_ptr;
} }
else else
{ {
*value |= *msg_ptr; *lsb_ptr |= *msg_ptr;
} }
return ERR_OK; return ERR_OK;
} }