0
#define INT_MAX 2147483647
#define INT_MIN (-INT_MAX-1)
int main()
{
    int secret = 0x12345678;
    int array[1] = {0};
    printf("%d",array[INT_MIN+1]);

} The code run without stack protector.

the question is about integer overflow, but i dont understand why it work because the value of INT_MIN + 1 is -2147483647. and if i want to print the value of secret, I need to write: array[-1]

1 Answers1

0

Looking at your code, The printf returns 0 as it is an array of int, not the secret. I think that there is an unpredictable behavior due to index outbound. You are declaring an array of 1 element but referring to an outbound index of the array. Maybe this post can help.

Raymi
  • 46
  • 6
  • im sorry i didn't mention it before, but the code work without stack protector –  Jun 24 '21 at 11:51