mirror of
https://github.com/systemd/systemd.git
synced 2026-08-04 15:10:33 +00:00
alloc-util: introduce MALLOC_SIZEOF_SAFE() helper
It's a wrapper around malloc_usable_size() that is supposed to be compatible with _FORTIFY_SOURCES=1, by taking the __builtin_object_size() data into account, the same way as the _FORTIFY_SOURCES=1 logic does. Fixes: #19203
This commit is contained in:
@@ -805,7 +805,7 @@ int strextendf(char **x, const char *format, ...) {
|
||||
/* Let's try to use the allocated buffer, if there's room at the end still. Otherwise let's extend by 64 chars. */
|
||||
if (*x) {
|
||||
m = strlen(*x);
|
||||
a = malloc_usable_size(*x);
|
||||
a = MALLOC_SIZEOF_SAFE(*x);
|
||||
assert(a >= m + 1);
|
||||
} else
|
||||
m = a = 0;
|
||||
@@ -821,7 +821,7 @@ int strextendf(char **x, const char *format, ...) {
|
||||
return -ENOMEM;
|
||||
|
||||
*x = n;
|
||||
a = malloc_usable_size(*x);
|
||||
a = MALLOC_SIZEOF_SAFE(*x);
|
||||
}
|
||||
|
||||
/* Now, let's try to format the string into it */
|
||||
|
||||
Reference in New Issue
Block a user