Hoo*_*oli 1 c stack-overflow debugging gdb
我有这个示例程序,当使用fstack-protector-all编译时会给出一个堆栈粉碎.
#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);
}
Run Code Online (Sandbox Code Playgroud)
我不明白这条线有什么问题.是否需要进行类型转换?