I have this sample program which when compiled with fstack-protector-all gives a stack smashing.
#include <stdio.h>
#include <stdint.h>
int func(int* value)
{
uint8_t port = 1;
*value = port; //Canary value changes at this point when seen in GDB
return 1;
}
int main()
{
uint16_t index = 0;
int ret = func((int*)&index);
}
I don't understand what is wrong with the line. Is any typecasting required?
gcc -fstack-protector yourcode.c. And it runs fine.