Skip to content

Latest commit

 

History

History
58 lines (49 loc) · 2.33 KB

README.md

File metadata and controls

58 lines (49 loc) · 2.33 KB

malloc

Sets debug flags which are interpreted by eglibc that are beneficial to defending malloc and friends.

For more information, see man 3 mallopt.

notes

This disables some of the diagnostic messages emitted to /dev/tty (or stderr) when heap corruption is detected.

It also increases the number of checks which are performed.

Finally, it perturbs data so that data is initialized on malloc to re-initialized on free such that you can't rely on the heap being zero-filled, or re-using old allocations.

usage

$ example/example
Fresh allocation
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
After strcpy
48 65 6C 6C 6F 2C 20 77  6F 72 6C 64 21 00 00 00  |  Hello, world!... 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
After free
00 00 00 00 00 00 00 00  6F 72 6C 64 21 00 00 00  |  ........orld!... 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
After 2nd malloc
00 00 00 00 00 00 00 00  6F 72 6C 64 21 00 00 00  |  ........orld!... 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
After 2nd free
00 00 00 00 00 00 00 00  6F 72 6C 64 21 00 00 00  |  ........orld!... 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
Before double-free
*** Error in `./example': double free or corruption (fasttop): 0x0000000001188010 ***
[1]    30596 abort (core dumped)  ./example
$ ./malloc example/example
Fresh allocation
80 80 80 80 80 80 80 80  80 80 80 80 80 80 80 80  |  ................ 
80 80 80 80 80 80 80 80  80 80 80 80 80 80 80 80  |  ................ 
After strcpy
48 65 6C 6C 6F 2C 20 77  6F 72 6C 64 21 00 80 80  |  Hello, world!... 
80 80 80 80 80 80 80 80  80 80 80 80 80 80 80 80  |  ................ 
After free
00 00 00 00 00 00 00 00  7F 7F 7F 7F 7F 7F 7F 7F  |  ................ 
7F 7F 7F 7F 7F 7F 7F 7F  7F 7F 7F 7F 7F 7F 7F 7F  |  ................ 
After 2nd malloc
80 80 80 80 80 80 80 80  80 80 80 80 80 80 80 80  |  ................ 
80 80 80 80 80 80 80 80  80 80 80 80 80 80 80 80  |  ................ 
After 2nd free
00 00 00 00 00 00 00 00  7F 7F 7F 7F 7F 7F 7F 7F  |  ................ 
7F 7F 7F 7F 7F 7F 7F 7F  7F 7F 7F 7F 7F 7F 7F 7F  |  ................ 
Before double-free
[1]    30615 abort (core dumped)  ../malloc ./example