[英]How do I tell clang memory sanitizer to ignore data from certain libraries?
For example I'd like to ignore sqlite and zlib because I know they're well tested.例如,我想忽略 sqlite 和 zlib,因为我知道它们已经过良好测试。 I grabbed the zpipe.c
example and built it like this.我抓取了zpipe.c
示例并像这样构建它。 Keep in mind I'm using -lz
and not building zlib myself.请记住,我使用的是-lz
而不是自己构建 zlib。 I'm only building zpipe myself and want to limit the sanitize to that one file我只是自己构建 zpipe,并希望将清理限制在那个文件中
clang -g -fsanitize=undefined,memory zpipe.c -lz
I ran echo Test |./a.out
and I got the following error我运行echo Test |./a.out
并收到以下错误
Uninitialized bytes in __interceptor_fwrite at offset 0 inside [0x7ffd61230bc0, 13)
==50435==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x55767941cd85 in def /tmp/zlib-1.2.12/examples/zpipe.c:70:17
#1 0x55767941e709 in main /tmp/zlib-1.2.12/examples/zpipe.c:186:15
#2 0x7f65e834e30f in __libc_start_call_main libc-start.c
#3 0x7f65e834e3c0 in __libc_start_main@GLIBC_2.2.5 (/usr/lib/libc.so.6+0x2d3c0)
#4 0x5576793981d4 in _start (/tmp/zlib-1.2.12/examples/a.out+0x211d4)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /tmp/zlib-1.2.12/examples/zpipe.c:70:17 in def
Is there a way I can say assume any data that goes in and out of zlib or sqlite to be safe to use?有没有一种方法可以让我假设进出 zlib 或 sqlite 的任何数据都可以安全使用? I'll be linking both and only want to sanitize my own code我将链接两者并且只想清理我自己的代码
You can use an ignore list file.您可以使用忽略列表文件。 https://clang.llvm.org/docs/SanitizerSpecialCaseList.html https://clang.llvm.org/docs/SanitizerSpecialCaseList.html
Usage:用法:
clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c
See the documentation for details on the format of the file.有关文件格式的详细信息,请参阅文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.