<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96772>96772</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
libfuzzer passes null pointers to functions whose parameters are marked __non_null
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
apasel422
</td>
</tr>
</table>
<pre>
[`Fuzzer::FileToVector`](https://github.com/llvm/llvm-project/blob/b579aacc30bc02e8430c0b59af644f52ece71160/compiler-rt/lib/fuzzer/FuzzerIO.cpp#L41) returns a `std::vector` whose `data` pointer is `nullptr` when the given file is empty.
Eventually, some of these `nullptr`s are passed as arguments to functions whose parameters are annotated as `__nonnull` (at least on some platforms), e.g. `memcpy`. Even though the 0-size is properly propagated, it is apparently still undefined behavior to pass null pointers in these cases, resulting in the UndefinedBehaviorSanitizer (correctly) flagging such instances.
- [`memcpy` example](https://github.com/llvm/llvm-project/blob/dead8f845f2549db5dec16b59b80d3e321948674/compiler-rt/lib/fuzzer/FuzzerLoop.cpp#L599) / [glibc declaration](https://sourceware.org/git/?p=glibc.git;a=blob;f=string/string.h;h=d2d5c5f1f91490bcc499d1391f9c9573f642bb99;hb=HEAD#l43)
- [`memcmp` example](https://github.com/llvm/llvm-project/blob/dead8f845f2549db5dec16b59b80d3e321948674/compiler-rt/lib/fuzzer/FuzzerLoop.cpp#L583) / [glibc declaration](https://sourceware.org/git/?p=glibc.git;a=blob;f=string/string.h;h=d2d5c5f1f91490bcc499d1391f9c9573f642bb99;hb=HEAD#l64)
Originally found in https://issues.chromium.org/issues/349505543.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVU2P5CYQ_TX0BY2FAX9w8GEmvVYirbSHfFxXGAqbBIMFuDc9vz7C7tnVJpGSKKe92O4qXvFe8bqQKdnZAwyoeUHN9SL3vIQ4yE0mcJzSyxT0_Ui2ZNxf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