diff --git a/core/snmp_encoder.c b/core/snmp_encoder.c index b95da03..8cc5f06 100644 --- a/core/snmp_encoder.c +++ b/core/snmp_encoder.c @@ -115,7 +115,7 @@ ber_uint_enc_try(unsigned int value) #else i = 0; - while (i < sizeof(unsigned int) && !a.buf[i]) { + while (i < (sizeof(unsigned int) - 1) && !a.buf[i]) { i++; } if (a.buf[i] & 0x80) { @@ -241,14 +241,14 @@ ber_int_enc(int value, uint8_t *buf) i = 0; if (value >= 0) { - while (i < sizeof(int) && !a.buf[i]) { + while (i < (sizeof(int) - 1) && !a.buf[i]) { i++; } if (a.buf[i] & 0x80) { buf[j++] = 0x0; } } else { - while (i < sizeof(int) && a.buf[i] == 0xff) { + while (i < (sizeof(int) - 1) && a.buf[i] == 0xff) { i++; } if (!(a.buf[i] & 0x80)) { @@ -296,7 +296,7 @@ ber_uint_enc(int value, uint8_t *buf) #else i = 0; - while (i < sizeof(unsigned int) && !a.buf[i]) { + while (i < (sizeof(unsigned int) - 1) && !a.buf[i]) { i++; } if (a.buf[i] & 0x80) { @@ -420,7 +420,7 @@ ber_length_enc_try(uint32_t value) len += i + 1; #else i = 0; - while (i < sizeof(uint32_t) && !a.buf[i]) { + while (i < (sizeof(uint32_t) - 1) && !a.buf[i]) { i++; } @@ -465,7 +465,7 @@ ber_length_enc(uint32_t value, uint8_t *buf) } #else i = 0; - while (i < sizeof(uint32_t) && !a.buf[i]) { + while (i < (sizeof(uint32_t) - 1) && !a.buf[i]) { i++; }