diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 103a48c5c..df4199837 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -34,6 +34,7 @@ static inline void buf_set_u32(uint8_t *_buffer, unsigned first, unsigned num, uint32_t value) { + assert(num >= 1 && num <= 32); uint8_t *buffer = _buffer; if ((num == 32) && (first == 0)) { @@ -64,6 +65,7 @@ static inline void buf_set_u32(uint8_t *_buffer, static inline void buf_set_u64(uint8_t *_buffer, unsigned first, unsigned num, uint64_t value) { + assert(num >= 1 && num <= 64); uint8_t *buffer = _buffer; if ((num == 32) && (first == 0)) { @@ -102,6 +104,7 @@ static inline void buf_set_u64(uint8_t *_buffer, static inline uint32_t buf_get_u32(const uint8_t *_buffer, unsigned first, unsigned num) { + assert(num >= 1 && num <= 32); const uint8_t *buffer = _buffer; if ((num == 32) && (first == 0)) { @@ -131,6 +134,7 @@ static inline uint32_t buf_get_u32(const uint8_t *_buffer, static inline uint64_t buf_get_u64(const uint8_t *_buffer, unsigned first, unsigned num) { + assert(num >= 1 && num <= 64); const uint8_t *buffer = _buffer; if ((num == 32) && (first == 0)) {