diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libutils/isoc/bget.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libutils/isoc/bget.c b/lib/libutils/isoc/bget.c index 6de0b091..f70a1145 100644 --- a/lib/libutils/isoc/bget.c +++ b/lib/libutils/isoc/bget.c @@ -597,12 +597,16 @@ void *bget(requested_size, poolset) } #ifdef SizeQuant #if SizeQuant > 1 - size = (size + (SizeQuant - 1)) & (~(SizeQuant - 1)); + if (ADD_OVERFLOW(size, SizeQuant - 1, &size)) + return NULL; + + size = ROUNDDOWN(size, SizeQuant); #endif #endif - size += sizeof(struct bhead); /* Add overhead in allocated buffer - to size required. */ + /* Add overhead in allocated buffer to size required. */ + if (ADD_OVERFLOW(size, sizeof(struct bhead), &size)) + return NULL; #ifdef BECtl /* If a compact function was provided in the call to bectl(), wrap |