Valgrind的不会检测缓冲区溢出 [英] Valgrind won't detect buffer overflow

查看:315
本文介绍了Valgrind的不会检测缓冲区溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我的valgrind预计检测上述code缓冲区溢出。但它没有报告任何错误或警告。我是否需要启用任何特殊标志是什么?

I expected valgrind to detect a buffer overflow with the above code. But it does not report any errors or warnings. Do I need to enable any special flags for that?

推荐答案

Valgrind的教程

什么的valgrind是不是

虽然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 ..

这篇关于Valgrind的不会检测缓冲区溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆