[libc-commits] [PATCH] D74091: [libc] Lay out framework for fuzzing libc functions.

Alex Brachet via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Feb 5 14:36:47 PST 2020


abrachet added inline comments.


================
Comment at: libc/fuzzing/string/strcpy_fuzz.cpp:7
+
+extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
+  if (size == 0) {
----------------
Does `oss-fuzz` require this to not be mangled?


================
Comment at: libc/fuzzing/string/strcpy_fuzz.cpp:8-10
+  if (size == 0) {
+    return 0;
+  }
----------------
No brackets here or the for and its if and also the last if. I think `!size` might be more common but I don't have a big preference.


================
Comment at: libc/fuzzing/string/strcpy_fuzz.cpp:14-20
+  for (size_t i = 0; i < size; i++) {
+    // replace early null-termination with valid character.
+    if (src[i] == '\0') {
+      src[i] = 'a';
+    }
+  }
+  src[size] = '\0';
----------------
Maybe we will eventually add free standing function templates like those found in <algorithm> so things like this can become `cpp::replace(data, data + size, 0, 'a')`


================
Comment at: libc/fuzzing/string/strcpy_fuzz.cpp:15
+  for (size_t i = 0; i < size; i++) {
+    // replace early null-termination with valid character.
+    if (src[i] == '\0') {
----------------
Capitilize replace


================
Comment at: libc/fuzzing/string/strcpy_fuzz.cpp:25-27
+  if (strcmp(dest, src) != 0) {
+    abort();
+  }
----------------
Is this not `assert(strcmp(dest, src))` because you think `NDEBUG` might be defined for this file?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74091/new/

https://reviews.llvm.org/D74091





More information about the libc-commits mailing list