+2003-08-19 Jeff Johnston <jjohnstn@redhat.com>
+
+ * libc/stdlib/mallocr.c (mALLOc, rEALLOc, mEMEALIGn): Enhance
+ overflow detection.
+
2003-08-13 Aldy Hernandez <aldyh@redhat.com>
* libc/machine/powerpc/machine/stdlib.h: Wrap SPE functions in
INTERNAL_SIZE_T nb = request2size(bytes); /* padded request size; */
/* Check for overflow and just fail, if so. */
- if (nb > INT_MAX)
+ if (nb > INT_MAX || nb < bytes)
return 0;
MALLOC_LOCK;
nb = request2size(bytes);
/* Check for overflow and just fail, if so. */
- if (nb > INT_MAX)
+ if (nb > INT_MAX || nb < bytes)
return 0;
#if HAVE_MMAP
/* Call malloc with worst case padding to hit alignment. */
nb = request2size(bytes);
+
+ /* Check for overflow. */
+ if (nb > INT_MAX || nb < bytes)
+ return 0;
+
m = (char*)(mALLOc(RCALL nb + alignment + MINSIZE));
if (m == 0) return 0; /* propagate failure */