Getting a Seg Fault
Nov 6, 2020 at 7:58pm UTC
Hey guys,
I seem to be getting a seg fault from a short rudimentary C program, the program just contains a char buffer (500 bytes) the string passed in from args is copied to buffer
But I seem to be getting a segfault even though I only fill my buffer up with 500 bytes,
1 2 3 4 5 6 7 8 9
#include <stdio.h>
#include <string.h>
int main(int argc,char ** argv){
char buffer[500];
strcpy(buffer,argv[1]);
return 0;
}
I used
gcc -g -m32 -fno-stack-protector vuln.c -o vuln
to compile the program
and
./sample $(python -c 'print "\x41" * 500' )
to run the application with 500 'A's
but I receive a seg fault,
I'm using Kali Linux if that is of any importance.
thanks
Last edited on Nov 6, 2020 at 8:00pm UTC
Nov 6, 2020 at 8:04pm UTC
strcpy also copies the null terminator.
Does your code crash if you do "A" * 499?
Last edited on Nov 6, 2020 at 8:05pm UTC
Nov 6, 2020 at 8:07pm UTC
ahh good point, I didn't even think of that as a possibility,
seems to work fine with 499 :) , only crashes at 500
Thanks
Topic archived. No new replies allowed.