summaryrefslogtreecommitdiff
path: root/src/basic/alloc-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-20 10:30:31 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-20 10:48:33 +0100
commite5e21a05076e60fe46eab4eb040735250ae3b814 (patch)
tree3e06e298230e365cde01b23a56c60b841c8ffb0e /src/basic/alloc-util.c
parente1ed99c8c89d6e4ca4df3e47617ff1f3e194cabb (diff)
downloadsystemd-e5e21a05076e60fe46eab4eb040735250ae3b814.tar.gz
alloc-util: extra paranoid overflow check
Diffstat (limited to 'src/basic/alloc-util.c')
-rw-r--r--src/basic/alloc-util.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/basic/alloc-util.c b/src/basic/alloc-util.c
index b28fb95ccf..15b67665d2 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;