1
votes

I am trying to run the program to test buffer overflow, but when program crashes it shows me SIGSEGV error as follows:

Program received signal SIGSEGV, Segmentation fault. 0x00000000004006c0 in main (argc=2, argv=0x7fffffffde78)

But the tutorial which I am following is getting the below message:

Program received signal SIGSEGV, Segmentation fault. 0x41414141 in ?? ()

Due to this I am not able to get the exact memory location of buffer overflow.

I have already used -fno-stack-protector while compiling my program. because before this I was getting SIGABRT error.

Does anyone have any clue so that i can get in sync with the tutorial.

2
Think about the implications of undefined behaviour! - too honest for this site
@Olaf Think about the fact that this question is about what actually happens and not what should happen according to the C standard! - user253751
@immibis: No, it is about what could happen and that there is no use in expecting undefined behaviour to behave a defined way. Nasal demons are always an option. - too honest for this site
Addresses are virtual and are not guaranteed to be exactly the same on different machines/OS versions, etc. Worst, there is some mechanism to counterstrike such attacks, for example : en.wikipedia.org/wiki/Address_space_layout_randomization... Don't rely on values, at least be careful... - Jean-Baptiste Yunès

2 Answers

2
votes

I was able to figure out the difference in both.

Actually I was trying the same code on Ubuntu 64-bit on virtual box. But then I tried installing Ubuntu 32-bit on virtual box, so now I am also getting the same message as what was coming in the tutorial.

Also another difference which I noticed in 64 bit and 32-bit OS is that when using 32 bit we can examine the stack using $esp but in 64-bit machine we have to use $rsp

0
votes

SIGSEGV is the signal raised when your program attempts to access a memory location where it is not supposed to do. Two typical scenarios are:

  • Deference a non-initialized pointer.
  • Access an array out-of-bound.

Note, however, even in these two cases, there is no guarantee that SIGSEGV always happen. So don't expect that SIGSEGV message is always the same even with the same code.