[PATCH] D27234: [libFuzzer] Diff 4 - Split FuzzerUtil implementation for Posix and Windows.

Kostya Serebryany via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 15:02:50 PST 2016


kcc added inline comments.


================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:217
   size_t N;
-  while ((N = fread(Buff, 1, sizeof(Buff), Pipe)) > 0)
+  while ((N = fread(Buff, 1, sizeof(Buff), Pipe)) == sizeof(Buff))
     Out->append(Buff, N);
----------------
zturner wrote:
> kcc wrote:
> > why this change from >0 to == sizeof(Buff)
> > 
> > In general, please avoid mixing refactoring and functionality changes. 
> That change was my suggestion.  The code is incorrect as written because `fread` doesn't use <= 0 to indicate an error, it uses != request_size, then you check `ferror`.  In any case, your point about mixing functionality and refactoring changes is still valid, so it might be worth doing this in a followup as you suggest.
hmmm.  am I reading "man fread" wrong? 
On success, fread() and fwrite() return the number of items read or written.  This number equals the number of bytes transferred only when size is 1.  If an error occurs, or the end of
       the file is reached, the return value is a short item count (or zero).



Repository:
  rL LLVM

https://reviews.llvm.org/D27234





More information about the llvm-commits mailing list