-
October 26th, 2005, 07:28 PM
#1
Junior Member
buffers and bytes
here's something i m lost about...a particular C code looks like this
int main(int argc,char **argv)
{
char buff[2];
strcpy(buff,argv[1]);
.....
some code
.....
}
The program gives segmentation fault if i pass argv[1] greater than 5 bytes ie starting from 6 bytes which implies 5 bytes can be copied to buff array.....now whys that and if its about over-writing saved frame pointer of 4 bytes ...then if i make buff of size 5 bytes ie char buff[5].........i can copy 27 bytes to it without segmentation fault which occurs when argv[1]>=28 bytes.................................
(word size is 4 bytes)
can someone explain......
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|