#include <string.h>
int main(int argc, char *argv[]){
unsigned short s;
int i;
char buf[80];
if(argc < 3){
return -1;
}
i = atoi(argv[1]);
s = i;
if(s >= 80){
printf("We dont allow big names.\n");
return -1;
}
strncpy(buf, argv[2], i);
printf("%s\n", buf);
return 0;
}
After compiling, execute it following way:
$ ./a.out 81 alpha0
We dont allow big names.
$./a.out 79 alpha0
alpha0
2 comments:
Amazing.
How to avoid it?
--Alpha0
Can anyone find bugs in rzo's solution?
Hey rzo,
Are you from Ring-of-fire?
#Alpha0
Post a Comment