Skip to content

Instantly share code, notes, and snippets.

@alipov
Created March 28, 2015 16:02
Show Gist options
  • Save alipov/c4bae95b775adcfa1b8e to your computer and use it in GitHub Desktop.
Save alipov/c4bae95b775adcfa1b8e to your computer and use it in GitHub Desktop.
buffer overflow example program
#include <string.h>
#include <stdio.h>
void foo (FILE * fileDescr)
{
char c[12];
long lSize;
fseek (fileDescr , 0 , SEEK_END);
lSize = ftell (fileDescr);
rewind (fileDescr);
fread(c, 1, lSize, fileDescr);
}
int main (int argc, char **argv)
{
FILE * fileDescr = NULL;
if(fileDescr = fopen(argv[1], "r"))
{
foo(fileDescr);
fclose(fileDescr);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment