[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
msan detects uninitialized variables in tar1.34
From: |
2773414454 |
Subject: |
msan detects uninitialized variables in tar1.34 |
Date: |
Wed, 8 Mar 2023 12:55:58 +0800 |
Hello.
Enable the msan compilation option and compile the tar1.34 in clang.(https://clang.llvm.org/docs/MemorySanitizer.html)
msan detects uninitialized variables in tar1.34
#/home/tar-1.34/src/tar -cf /home/new.tar /home/lost+found/
/home/tar-1.34/src/tar: Removing leading ??/' from member names
==832799==MemorySanitizer: use-of-uninitialized-value
#0 0x4d3411 (/home/tar-1.34/src/tar+0x4d3411)
#1 Ox4cdfb7 (/home/tar-1.34/src/tar+0x4cdfb7)
#2 0x54bbb7 (/home/tar-1.34/src/tar+0x54bbb7)
#3 Ox7ff1320ab20f (/usr/1ib64/libc.so.6+0x2d20f)
#4 Ox7ff1320ab2bb = (/usr/1ib64/libc.so.6+0x2d2bb)
#5 0x42b9a4 (/home/tar-1.34/src/tar+0x42b9a4)
Uninitialized value was created by an allocation of ??final_stat' in the stack frame of function ??dump filed"
#0 0x4cee90 (/home/tar-1.34/src/tar+0x4cee90)
SUMMARY: MemorySanitizer: use-of-uninitialized-value (/home/tar-1.34/src/tar+0x4d3411)
Exiting
After initialization is added to the stbuf structure, recompile the stbuf structure and run the test. The corresponding MSAN alarm is cleared.
src/system.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/system.c b/src/system.c
index 2988ed08..76db1f38 100644
--- a/src/system.c
+++ b/src/system.c
@@ -283,6 +283,7 @@ static int
is_regular_file (const char *name)
{
struct stat stbuf;
+ memset(&stbuf,0,sizeof(struct stat));
if (stat (name, &stbuf) == 0)
return S_ISREG (stbuf.st_mode);
| 2773414454 2773414454@qq.com |
0001-Initializing-variable-struct-stat-stbuf-memory.patch.txt
Description: Binary data
- msan detects uninitialized variables in tar1.34,
2773414454 <=