File: ftest2.c

package info (click to toggle)
debauch 0.3-11
  • links: PTS
  • area: main
  • in suites: potato
  • size: 220 kB
  • ctags: 685
  • sloc: ansic: 2,136; makefile: 531; sh: 84; asm: 34
file content (19 lines) | stat: -rw-r--r-- 391 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <stdlib.h>

main()
{
  char *a,*b;

  a=malloc(1024);
  b=malloc(1024);
  b=0;              /* lose reference to b */
  a[-1]='\0';       /* corrupt head of a */
  a[1024]='\0';     /* corrupt tail of a */
  free(a);   
  a[0]=0;           /* store to free'd memory */
  a[1]=0;           /* store to middle of free'd memory */

  b=malloc(1024);   
  free(b);
}