gpt4 book ai didi

c - Valgrind 不会检测缓冲区溢出

转载 作者:太空狗 更新时间:2023-10-29 16:47:51 27 4
gpt4 key购买 nike

#include <stdio.h>
main()
{
char buf[8];
sprintf(buf,"AAAA%3s","XXssssssssXXXsssssXXX");
printf("%s\n",buf);
}

我希望 valgrind 使用上述代码检测到缓冲区溢出。但它不报告任何错误或警告。我需要为此启用任何特殊标志吗?

最佳答案

来自 Valgrind Tutorial

valgrind 不是什么

Although valgrind is an extremely useful program, it will not miraculously tell you about every memory bug in your program. There are several limitations that you should keep in mind. It does not do bounds checking on stack/static arrays ..

关于c - Valgrind 不会检测缓冲区溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29842747/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com