alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhere
Let's define two helpers strdupa_safe() + strndupa_safe() which do the same as their non-safe counterparts, except that they abort if called with allocations larger than ALLOCA_MAX. This should ensure that all our alloca() based allocations are subject to this limit. afaics glibc offers three alloca() based APIs: alloca() itself, strndupa() + strdupa(). With this we have now replacements for all of them, that take the limit into account.
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ int rmdir_parents(const char *path, const char *stop) {
|
||||
if (!path_is_safe(stop))
|
||||
return -EINVAL;
|
||||
|
||||
p = strdupa(path);
|
||||
p = strdupa_safe(path);
|
||||
|
||||
for (;;) {
|
||||
char *slash = NULL;
|
||||
|
||||
Reference in New Issue
Block a user