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

Paula Toth via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Feb 13 13:56:40 PST 2020


PaulkaToast added inline comments.


================
Comment at: libc/fuzzing/string/strcpy_fuzz.cpp:13
+  char *src = (char *)malloc(size + 1);
+  memcpy(src, data, size);
+  for (size_t i = 0; i < size; i++) {
----------------
MaskRay wrote:
> Placing malloc in the function LLVMFuzzerTestOneInput may make tests run slowly.
The test case is rather simple so it runs sufficiently fast about 150k+ executions per second on one of my machine's cores.

Since we cannot modify the fuzzer input data the only alternative would be using a static buffer, however that introduces a size constraint and we could miss a bug with bigger strings.


================
Comment at: libc/fuzzing/string/strcpy_fuzz.cpp:25
+
+  if (strcmp(dest, src) != 0) {
+    abort();
----------------
MaskRay wrote:
> Braces around a single statement are not common in LLVM code. I think Google code tends to have more braces because:
> 
> ```
> % cat a.c
> int main() {
>   if (strcmp(dest, src) != 0)
>     abort();
> }
> % clang-format --style=Google a.c
> int main() {
>   if (strcmp(dest, src) != 0) abort();
> }
> ```
> 
> Many consider `if (...) ...` on the same line strange. LLVM style does not have the problem.
Ah, thank you!


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