File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 14
14
15
15
#include " src/libfuzzer/libfuzzer_mutator.h"
16
16
17
+ #if defined(__has_feature)
18
+ # if __has_feature(memory_sanitizer)
19
+ #include < sanitizer/msan_interface.h>
20
+ # endif
21
+ #endif
17
22
#include < string.h>
18
23
19
24
#include < algorithm>
@@ -65,6 +70,12 @@ T MutateValue(T v) {
65
70
size_t size =
66
71
LLVMFuzzerMutate (reinterpret_cast <uint8_t *>(&v), sizeof (v), sizeof (v));
67
72
memset (reinterpret_cast <uint8_t *>(&v) + size, 0 , sizeof (v) - size);
73
+ // The value from LLVMFuzzerMutate needs to be treated as initialized.
74
+ #if defined(__has_feature)
75
+ # if __has_feature(memory_sanitizer)
76
+ __msan_unpoison (&v, sizeof (v));
77
+ # endif
78
+ #endif
68
79
return v;
69
80
}
70
81
@@ -93,6 +104,12 @@ std::string Mutator::MutateString(const std::string& value,
93
104
result.resize (std::max (1 , new_size));
94
105
result.resize (LLVMFuzzerMutate (reinterpret_cast <uint8_t *>(&result[0 ]),
95
106
value.size (), result.size ()));
107
+ // The value from LLVMFuzzerMutate needs to be treated as initialized.
108
+ #if defined(__has_feature)
109
+ # if __has_feature(memory_sanitizer)
110
+ __msan_unpoison (&result[0 ], result.size ());
111
+ # endif
112
+ #endif
96
113
return result;
97
114
}
98
115
You can’t perform that action at this time.
0 commit comments