Created
February 18, 2013 19:19
-
-
Save anonymous/4979855 to your computer and use it in GitHub Desktop.
Wooo! Gists!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Errors: | |
-) There is a buffer overflow when passing words of length >= 100. | |
-) There is a problem for words containing "%s". | |
-) The file descriptor is never closed. | |
-) All whitespace is removed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define SUCCESS 0 | |
#define E_PARAM 1 | |
int main(int argc, char **argv) | |
{ | |
int i; | |
FILE *in; | |
char c; | |
if(argc==0) | |
{ | |
fprintf(stderr, "ERROR: Not enough parameters.\n"); | |
fprintf(stderr, "Syntax: %s [file1] [file2] ... [fileN]\n", argv[0]); | |
exit(E_PARAM); | |
} | |
for(i=1;i<argc;i++) | |
{ | |
in = fopen(argv[i], "r"); | |
if(in==NULL) | |
fprintf(stderr, "\n%s: %s: No such file or directory\n", argv[0], argv[i]); | |
else while ((c = fgetc(in)) != EOF) | |
{ | |
putchar(c); | |
} | |
fclose(in); | |
} | |
exit(SUCCESS); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goodcat: goodcat.o | |
cc goodcat.o -o goodcat | |
clean: | |
rm goodcat.o goodcat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment