-1

每当我尝试这样做时:

char buffed[1024];
snprintf(buffed, sizeof(buffed), "bash.sh %s &", get_value("request-uri"));
system(buffed);

这是我使用的功能:

char *get_value(char *name) {
        FORMAT_NODE *node;

#ifdef DEBUG
        ASSERT(name);
#endif

        if (strlen(name) == 0)
                return EMPTY_FIELD;

        if ((node = get_field(name))) {
                return node->value;
        } else {
                return EMPTY_FIELD;
        }
}

编译是可以的,但是每当它应该打印它给出分段错误和崩溃的值时,有人可以解释我做错了什么吗?

提前致谢!

编辑:

get_value("request-uri") 是我所说的,它应该是一个字符串

strstr(get_value("request-uri"), "index.php") 完美运行!

但“index.php”应该来自 get_value

编辑2:gdb:程序收到信号SIGSEGV,分段错误。来自 /lib64/libc.so.6 的 __strlen_sse2 () 中的 0x00007ffff73f3321

4

1 回答 1

0

这里的问题由 CBIII 解决,因为它告诉我使用 gdb,该值是空的,因为它在使用之前已刷新。

get_value("request-uri") 返回 0x0

于 2013-08-03T13:25:39.713 回答