aboutsummaryrefslogtreecommitdiff
path: root/overflow.c
blob: 8fb07b9e93ee226f4188c0afd7f8bd552b5d3259 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * overflow.c
 *
 *  Created on: 27.01.2012
 *      Author: druid
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/* 300 bytes buffer len + 4 bytes for overwrite return opcode */
#define BUFLEN    300

void
overflow(const char *src, char *dst)
{
  /* exploitable function */
  strcpy(dst, src);
  /* nothing to do, just return */
}

int
main(int argc, char **argv)
{
  char buf[BUFLEN];

  if (argc > 1) {
      overflow(argv[1], buf);
  } else {
    fprintf(stderr, "arg1 missing\n");
    return(1);
  }

  return (0);
}