#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
void *chunk1;
void *chunk2;
void *chunk3;
void *chunk4;
chunk1 = malloc(24);
strcpy(chunk1, "abcde");
free(chunk1);
chunk2 = malloc(24);
strcpy(chunk2, "12345");
free(chunk2);
chunk3 = malloc(24);
strcpy(chunk3, "98765");
free(chunk3);
chunk4 = malloc(24);
strcpy(chunk4, "23456");
free(chunk4);
return 0;
}
#if 0
12 chunk1 = malloc(24);
(gdb) x/48wx chunk1
0x42ca3000: 0x42ca2d88 0x42aff316 0x00000000 0x42c1dc70
0x42ca3010 <realloc@got.plt>: 0x42b60de0 0x42b60920 0x42b90510 0x42b61110
0x42ca3020 <*ABS*@got.plt>: 0x42b7e740 0x42c3cd00 0x42ad7e40 0x42b61250
0x42ca3030 <___tls_get_addr@got.plt>: 0x42ad6fa0 0x42b60ce0 0x42c42c90 0x00000000
0x42ca3040 <__libc_multiple_libcs>: 0x00000001 0x0000037f 0x00000040 0x00000022
0x42ca3050: 0x00000000 0x00000000 0x00000000 0x00000000
0x42ca3060 <randtbl>: 0x00000003 0x991539b1 0x16a5bce3 0x6774a4cd
0x42ca3070 <randtbl+16>: 0x3e01511e 0x4e508aaa 0x61048c05 0xf5500617
0x42ca3080 <randtbl+32>: 0x846b7115 0x6a19892c 0x896a97af 0xdb48f936
0x42ca3090 <randtbl+48>: 0x14898454 0x37ffd106 0xb58bff9c 0x59e17104
0x42ca30a0 <randtbl+64>: 0xcf918a49 0x09378c83 0x52c7a471 0x8d293ea9
0x42ca30b0 <randtbl+80>: 0x1f4fc301 0xc3db71be 0x39b44e1c 0xf8a44ef9
(gdb) n
13 strcpy(chunk1, "abcde");
(gdb)
14 free(chunk1);
(gdb) x/48wx chunk1-8
0x804b000: 0x00000000 0x00000021 0x64636261 0x00000065
0x804b010: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b020: 0x00000000 0x00020fe1 0x00000000 0x00000000
0x804b030: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b040: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b050: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b060: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b070: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b080: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b090: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0a0: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0b0: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) n
16 chunk2 = malloc(24);
(gdb) x/48wx chunk1-8
0x804b000: 0x00000000 0x00000021 0x00000000 0x00000065
0x804b010: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b020: 0x00000000 0x00020fe1 0x00000000 0x00000000
0x804b030: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b040: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b050: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b060: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b070: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b080: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b090: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0a0: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0b0: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) n
17 strcpy(chunk2, "12345");
(gdb)
18 free(chunk2);
(gdb) x/48wx chunk1-8
0x804b000: 0x00000000 0x00000021 0x34333231 0x00000035
0x804b010: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b020: 0x00000000 0x00020fe1 0x00000000 0x00000000
0x804b030: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b040: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b050: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b060: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b070: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b080: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b090: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0a0: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0b0: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) n
20 chunk3 = malloc(24);
(gdb) x/48wx chunk1-8
0x804b000: 0x00000000 0x00000021 0x00000000 0x00000035
0x804b010: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b020: 0x00000000 0x00020fe1 0x00000000 0x00000000
0x804b030: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b040: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b050: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b060: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b070: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b080: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b090: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0a0: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0b0: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) n
21 strcpy(chunk3, "98765");
(gdb)
22 free(chunk3);
(gdb) x/48wx chunk1-8
0x804b000: 0x00000000 0x00000021 0x36373839 0x00000035
0x804b010: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b020: 0x00000000 0x00020fe1 0x00000000 0x00000000
0x804b030: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b040: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b050: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b060: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b070: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b080: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b090: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0a0: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0b0: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) n
24 chunk4 = malloc(24);
(gdb) x/48wx chunk1-8
0x804b000: 0x00000000 0x00000021 0x00000000 0x00000035
0x804b010: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b020: 0x00000000 0x00020fe1 0x00000000 0x00000000
0x804b030: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b040: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b050: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b060: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b070: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b080: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b090: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0a0: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0b0: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) n
25 strcpy(chunk4, "23456");
(gdb)
26 free(chunk4);
(gdb) x/48wx chunk1-8
0x804b000: 0x00000000 0x00000021 0x35343332 0x00000036
0x804b010: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b020: 0x00000000 0x00020fe1 0x00000000 0x00000000
0x804b030: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b040: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b050: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b060: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b070: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b080: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b090: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0a0: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0b0: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) n
28 return 0;
(gdb) x/48wx chunk1-8
0x804b000: 0x00000000 0x00000021 0x00000000 0x00000036
0x804b010: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b020: 0x00000000 0x00020fe1 0x00000000 0x00000000
0x804b030: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b040: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b050: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b060: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b070: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b080: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b090: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0a0: 0x00000000 0x00000000 0x00000000 0x00000000
0x804b0b0: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) n
29 }
#endif

141

被折叠的 条评论
为什么被折叠?



