Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

ENTERPRISE UNICODE DETECTOR AND READER

Name: Anonymous 2012-01-12 20:35


#include <stdio.h>

int main(void) {
  char buff[256];
  char c;
  FILE *f;

  f = fopen("filename", "r");
  c = fgetc(f);
  if(c < 0) {
    fclose(f);
    system("type filename > filename.tmp");
    f = fopen("filename.tmp", "r");
  }
  else {
    rewind(f);
  }

  while(fgets(buff, 256, f) != NULL)
    puts(f);

  fclose(f);
 
  return(0);
}

Name: Anonymous 2012-01-12 21:46

No buffer overflow prevention, therefore highly exploitable. What if ``filename'' was malicious machine code and you overflowed the buffer, causing malicious machine code to spill into the saved call point in memory, causing the code to run when the function returned? You're screwed.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List