From 30e5a1fd1f307763dd2c196adc30593d8b7902e5 Mon Sep 17 00:00:00 2001 From: vms Date: Sun, 5 May 2019 20:59:48 +0400 Subject: [PATCH] move to __builtin_add_overflow --- libc-bottom-half/mman/mman.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libc-bottom-half/mman/mman.c b/libc-bottom-half/mman/mman.c index e0b1021..575a495 100644 --- a/libc-bottom-half/mman/mman.c +++ b/libc-bottom-half/mman/mman.c @@ -58,10 +58,9 @@ void *mmap(void *addr, size_t length, int prot, int flags, return MAP_FAILED; } - const size_t buf_len = sizeof(struct map) + length; - // Check for integer overflow. - if(buf_len < length) { + size_t buf_len = 0; + if(__builtin_add_overflow(length, sizeof(struct map), &buf_len)) { errno = EINVAL; return MAP_FAILED; }