'
This commit is contained in:
commit
d0bd16da2f
9 changed files with 97 additions and 0 deletions
21
beware_overflow/main.c
Normal file
21
beware_overflow/main.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "beware_overflow.h"
|
||||
|
||||
void print_overflow(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
void *begin = ptr;
|
||||
void *res = beware_overflow(ptr, nmemb, size);
|
||||
if (res)
|
||||
printf("Pointer was incremented from %p to %p.\n", begin, res);
|
||||
else
|
||||
printf("Overflow detected between %ld and %ld.\n", nmemb, size);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
print_overflow((void *)0x1000, 25, 6);
|
||||
print_overflow((void *)0x40000, 12345678904, 12345678904);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue