Merge pull request #2 from jlamothe/master

prevent buffer overflow in filename
master
silverwizard 11 years ago
commit 65b2288d0b
  1. 5
      dpu.c

@ -23,6 +23,11 @@ int main (int argc, char **argv){
fputs("I pity the fool who don't have an input file!\n",stderr); fputs("I pity the fool who don't have an input file!\n",stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(strlen(argv[arg]) >= FILENAME_MAX - 4)
{
fputs("It's a filename, not a novel.\n", stderr);
return EXIT_FAILURE;
}
strcpy(name,argv[arg]); strcpy(name,argv[arg]);
strcat(name,".dpu"); strcat(name,".dpu");
if((bob = fopen(argv[arg],"r"))==NULL){ if((bob = fopen(argv[arg],"r"))==NULL){

Loading…
Cancel
Save