projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e1ed99c
)
alloc-util: extra paranoid overflow check
author
Lennart Poettering
<lennart@poettering.net>
Wed, 20 Mar 2019 09:30:31 +0000
(10:30 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Wed, 20 Mar 2019 09:48:33 +0000
(10:48 +0100)
src/basic/alloc-util.c
patch
|
blob
|
history
diff --git
a/src/basic/alloc-util.c
b/src/basic/alloc-util.c
index
b28fb95
..
15b6766
100644
(file)
--- 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;