Skip to content

Instantly share code, notes, and snippets.

@labeneator
Created February 27, 2013 16:04
Show Gist options
  • Save labeneator/5049033 to your computer and use it in GitHub Desktop.
Save labeneator/5049033 to your computer and use it in GitHub Desktop.
Leaky program
#include <stdio.h>
#include <unistd.h>
#include <string.h>
void open_file(char *filename)
{
FILE *fd = fopen(filename, "r");
}
int main(void)
{
char filename[FILENAME_MAX];
strcpy(filename, "/etc/passwd");
int iteration = 0;
while (1) {
iteration++;
printf("Iteration %d\n", iteration);
open_file(filename);
sleep(60);
}
return 0;
}
@labeneator
Copy link
Author

How to compile
$ gcc -g leaky.c -o leaky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment