mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-29 06:46:38 -04:00
spa: add spa_alloca that does overflow and limit checks
Make a function like alloca but with overflow checks and a max allocation size. Use this function where we can and also make sure that all alloca calls are in some way limited.
This commit is contained in:
parent
a9f1ad414e
commit
ed2c0ad4ee
10 changed files with 84 additions and 51 deletions
|
|
@ -457,6 +457,16 @@ struct spa_error_location {
|
|||
_strp; \
|
||||
})
|
||||
|
||||
#define spa_alloca(n, size, max_size) \
|
||||
({ \
|
||||
void *_res = NULL; \
|
||||
if ((size_t)n > (size_t)max_size / (size_t)size) \
|
||||
errno = ENOMEM; \
|
||||
else \
|
||||
_res = alloca((size_t)n * (size_t)size); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue