[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Wei Liu writes ("Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer"): > On Tue, Jan 24, 2017 at 05:05:16PM +0000, Ian Jackson wrote: > > If you use read you ought to put it in a loop to cope with potential > > partial reads. > > Does fread have better properties than read? Yes. fread is not allowed to give a short read for no particular reason, nor to return with EINTR. > I think to deal with short read we would need to stat the file to > get actual size for both fread and read, right? No. In both cases, it is possible to detect whether a short read is due to EOF. With read, that would have to be in a loop. With fread you can test feof. You don't need to test with stat unless you want to support files bigger than your static buffer. I recommend you: * use fopen and fread * complain if fread filled the whole buffer, on the grounds that that means you may be ignoring a longer file than is supported * check with feof or ferror that the short read was due to eof Ian. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |