Use *array() allocation functions where appropriate
This prevents overflow from multiplication. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
727275a027
commit
191f04f7dc
@@ -319,7 +319,7 @@ static bool append_range(struct subid_range **ranges, const struct subordinate_r
|
||||
return false;
|
||||
} else {
|
||||
struct subid_range *alloced;
|
||||
alloced = realloc(*ranges, (n + 1) * (sizeof(struct subid_range)));
|
||||
alloced = reallocarray(*ranges, n + 1, sizeof(struct subid_range));
|
||||
if (!alloced)
|
||||
return false;
|
||||
*ranges = alloced;
|
||||
@@ -911,7 +911,7 @@ static int append_uids(uid_t **uids, const char *owner, int n)
|
||||
return n;
|
||||
}
|
||||
|
||||
ret = realloc(*uids, (n + 1) * sizeof(uid_t));
|
||||
ret = reallocarray(*uids, n + 1, sizeof(uid_t));
|
||||
if (!ret) {
|
||||
free(*uids);
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user