diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2019-04-24 22:54:04 +0200 |
---|---|---|
committer | Tobias Stoeckmann <tobias@stoeckmann.org> | 2019-04-26 18:15:57 +0200 |
commit | bd817009d5dba7dc5273e6a05e2133660d4c4ac3 (patch) | |
tree | 40954140ed4859406ef56efd2851e084cffee77a /evmap.c | |
parent | 4a1088baf40928673317f10614fb15da9933ad4e (diff) | |
download | libevent-bd817009d5dba7dc5273e6a05e2133660d4c4ac3.tar.gz |
Prevent endless loop in evmap_make_space.
If slot is larger than INT_MAX / 2, then the loop which increases
nentries until it is larger than slot would never return.
Also make sure that nentries * msize will never overflow INT_MAX.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'evmap.c')
-rw-r--r-- | evmap.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -208,9 +208,15 @@ evmap_make_space(struct event_signal_map *map, int slot, int msize) int nentries = map->nentries ? map->nentries : 32; void **tmp; + if (slot > INT_MAX / 2) + return (-1); + while (nentries <= slot) nentries <<= 1; + if (nentries > INT_MAX / msize) + return (-1); + tmp = (void **)mm_realloc(map->entries, nentries * msize); if (tmp == NULL) return (-1); |