File: bof.c

package info (click to toggle)
gccintro 1.0-5
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 3,028 kB
  • sloc: ansic: 1,004; sh: 506; cpp: 172; makefile: 16
file content (23 lines) | stat: -rw-r--r-- 494 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define DESTLEN 8
int main(int argc, char** argv)
{
  char dest[DESTLEN];
  if (argc == 2)
    {
      printf(">>> Before the possible buffer over flow >>>\n");
      strcpy(dest, argv[1]);
      printf("<<< After the possible buffer over flow <<<\n");
    }
  else
    {
      fprintf(stderr,"Usage: %s ARG\n", argv[0]);
      fprintf(stderr,"       Character length(ARG) < %i bytes\n", DESTLEN);
      exit(1);
    }
  return 0;
}