'
This commit is contained in:
commit
d0bd16da2f
9 changed files with 97 additions and 0 deletions
11
beware_overflow/beware_overflow.c
Normal file
11
beware_overflow/beware_overflow.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include "beware_overflow.h"
|
||||
|
||||
void *beware_overflow(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
size_t c;
|
||||
if (__builtin_mul_overflow(nmemb, size, &c))
|
||||
return NULL;
|
||||
|
||||
char *byte_ptr = ptr;
|
||||
return c + byte_ptr;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue