From: Lennart Poettering Date: Wed, 20 Mar 2019 09:30:31 +0000 (+0100) Subject: alloc-util: extra paranoid overflow check X-Git-Tag: v242-rc1~103^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e5e21a05076e60fe46eab4eb040735250ae3b814;p=thirdparty%2Fsystemd.git alloc-util: extra paranoid overflow check --- diff --git a/src/basic/alloc-util.c b/src/basic/alloc-util.c index b28fb95ccfd..15b67665d26 100644 --- a/src/basic/alloc-util.c +++ b/src/basic/alloc-util.c @@ -27,6 +27,9 @@ void* memdup_suffix0(const void *p, size_t l) { /* The same as memdup() but place a safety NUL byte after the allocated memory */ + if (_unlikely_(l == SIZE_MAX)) /* prevent overflow */ + return NULL; + ret = malloc(l + 1); if (!ret) return NULL;