Merge branch 'calloc_overflow_check' into 'master'

add calloc integer overflow check

See merge request redox-os/relibc!188
This commit is contained in:
jD91mZM2
2019-02-28 08:20:11 +00:00
2 changed files with 16 additions and 5 deletions
+5
View File
@@ -1,6 +1,7 @@
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h> /* for SIZE_MAX */
int main(void) {
char * ptr = (char *)malloc(256);
@@ -18,6 +19,10 @@ int main(void) {
}
free(ptrc);
char * ptrco = (char *)calloc(SIZE_MAX, SIZE_MAX);
printf("calloc (overflowing) %p\n", ptrco);
free(ptrco); /* clean up correctly even if overflow is not handled */
char * ptra = (char *)memalign(256, 256);
printf("memalign %p\n", ptra);
for(i = 0; i < 256; i++) {