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:
Lennart Poettering
2021-05-19 16:42:00 +02:00
parent 871a3a33bb
commit 6df28e1f84
4 changed files with 17 additions and 5 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ static inline void* erase_and_free(void *p) {
if (!p)
return NULL;
l = malloc_usable_size(p);
l = MALLOC_SIZEOF_SAFE(p);
explicit_bzero_safe(p, l);
return mfree(p);
}