File: wrong7.c

package info (click to toggle)
duma 2.5.21-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,460 kB
  • sloc: ansic: 5,512; cpp: 2,205; makefile: 441; javascript: 191; sh: 129
file content (14 lines) | stat: -rw-r--r-- 305 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>

int main() {
  int *p;

  p = (int*) malloc( sizeof(int) * 10 );
  printf("Now writing before our allocated array\n");
  p[-1] ^= 0x0F; /* bash before */
  printf("... and now after our allocated array\n");
  p[10] ^= 0x0F; /* bash after */
  printf("Did you notice?\n");
  free(p);

}