![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| segmentation fault | rockgal | High Level Programming | 8 | 12-05-2006 08:16 AM |
| Segmentation Fault | compbug | UNIX for Dummies Questions & Answers | 3 | 04-21-2006 07:43 AM |
| segmentation fault | wojtyla | High Level Programming | 3 | 02-19-2005 10:53 AM |
| Segmentation fault | jshaulis | AIX | 1 | 06-01-2004 01:16 PM |
| segmentation fault | omran | High Level Programming | 2 | 08-01-2003 05:19 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Why not a segmentation fault??
Hi,
Why I don't receive a segmentation fault in the following sample. int main(void) { char buff[10]; sprintf(buff,"Hello world"); printf("%s\n",buff); } If I define a buffer of 10 elements and I'm trying to put inside it twelve elements, Should I receive a sigsev signal??? Thanks in advance! |
| Forum Sponsor | ||
|
|
|
|||
|
Actually, not quite.
SegFault (in this case) goes when the EIP register point's to a invalid memory address to execute, and just 2 bytes aren't enough to reach the EIP, however try with 500 chars , you should get your SegFault. |
|
|||
|
Thanks!
Hi Zarnick,
So, you mean that when I overwrite the return instruction pointer on the procedure stack I should receive a SegFault, but if I don't reach it I don't? and why not 2 bytes aren't enough?? Sorry, I don't want to be annoying! Thanks!! |
|
|||
|
I wouldn't know for sure why 2 bytes are just not enough, I think it's something to do with the pointers used to allocate the enough memory for your char[10] string. But I can be wrong on this one.
And at least from what I can remember, I never saw a segfault that wasn't about the EIP register being overruned, as always, I can be wrong. |
|||
| Google UNIX.COM |