首页 > 解决方案 > Stack-Smashing Protection 错误消息不包含程序名称

问题描述

这是一个非常丑陋的 C 程序:

#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
    char buffer[10];
    memcpy(buffer,argv[1],strlen(argv[1]));
    printf("%s\n", buffer);
    return 0;
}

我正在用 Stack-Smashing Protection 编译这个程序:

$ gcc -fstack-protector smash.c -o smash

这是我在执行期间得到的:

$ ./smash 01234567890
01234567890v?\??nr?!??U
*** stack smashing detected ***: <unknown> terminated

保护工作正常,但我不明白为什么我看到而不是argv[0].

标签: cstack-smash

解决方案


推荐阅读