mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
Add os_realloc_array() wrapper
This function can be used as a wrapper for os_realloc(ptr, nmemb * size) when a reallocation is used for an array. The main benefit over os_realloc() is in having an extra check to catch integer overflows in multiplication. This is similar to the os_zalloc() to os_calloc() move. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
f9884c096a
commit
b0cda9bd46
@ -486,6 +486,14 @@ char * os_strdup(const char *s);
|
|||||||
#endif /* OS_NO_C_LIB_DEFINES */
|
#endif /* OS_NO_C_LIB_DEFINES */
|
||||||
|
|
||||||
|
|
||||||
|
static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
if (size && nmemb > (~(size_t) 0) / size)
|
||||||
|
return NULL;
|
||||||
|
return os_realloc(ptr, nmemb * size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* os_strlcpy - Copy a string with size bound and NUL-termination
|
* os_strlcpy - Copy a string with size bound and NUL-termination
|
||||||
* @dest: Destination
|
* @dest: Destination
|
||||||
|
Loading…
Reference in New Issue
Block a user