]> granicus.if.org Git - libevent/commit
Add argument checks to some memory functions in `event.c'.
authorMansour Moufid <mansourmoufid@gmail.com>
Fri, 14 Oct 2011 21:16:03 +0000 (17:16 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 20 Oct 2011 03:21:57 +0000 (23:21 -0400)
commitc8953d1b4863e7484bf0afb42758644a16004cb9
tree60b1d461eec2211d822f0787e242281c49281491
parent128c8d6c0f684b95a98358805eb91e1384dcb050
Add argument checks to some memory functions in `event.c'.

Add a zero check to the function `event_mm_malloc_',
i.e. simply return NULL if the sz argument is zero.
On failure, set errno to ENOMEM and return NULL.

Add a zero check to the function `event_mm_calloc_',
i.e. simply return NULL if either argument is zero.
Also add an unsigned integer multiplication check, and if an integer
overflow would occur, set errno to ENOMEM and return NULL.
On failure, set errno to ENOMEM and return NULL.

Add a NULL check to the function `event_mm_strdup_',
i.e. set errno to EINVAL and return NULL.
Also add an unsigned integer addition check, and if an integer
overflow would occur, set errno to ENOMEM and return NULL.
If a memory allocation error occurs, again set errno to ENOMEM
and return NULL.

Add unit tests to `test/regress_util.c'.
event.c
mm-internal.h
test/regress_util.c