llvm-project
bde4ffe7 - Don't pass null pointers to memcmp and memcpy in libFuzzer (#96775)

Commit
1 year ago
Don't pass null pointers to memcmp and memcpy in libFuzzer (#96775) In C, it is UB to call `memcmp(NULL, NULL, 0)`, `memcpy(NULL, NULL, 0)`, etc. Unfortunately, `(NULL, 0)` is the natural representation of an empty sequence of objects and extremely common in real world code. As a result, all C code, and C++ code which calls into C functions, must carefully guard all calls to `memcpy`. This is a serious, real world usability issue in C and should be fixed in the language (see #49459). In the meantime, pay the cost of the extra branch to avoid tripping UBSan in libFuzzer. Once the usability problem in C has been fixed, these checks can be removed. Fixes #96772
Author
Parents
Loading