From: Ian Jackson <ian.jackson@eu.citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
Xen-devel <xen-devel@lists.xenproject.org>,
Jan Beulich <jbeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer
Date: Tue, 24 Jan 2017 17:22:37 +0000 [thread overview]
Message-ID: <22663.36189.603393.162103@mariner.uk.xensource.com> (raw)
In-Reply-To: <20170124171820.usctmtp3q6roxgnf@citrix.com>
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@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-01-24 17:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 12:11 [PATCH 0/4] fuzz: basic AFL support Wei Liu
2017-01-20 12:11 ` [PATCH 1/4] tools/fuzz: add missing dependency in x86 insn fuzzer build rule Wei Liu
2017-01-20 12:11 ` [PATCH 2/4] tools/fuzz: add AFL stub program for x86 insn emulator fuzzer Wei Liu
2017-01-24 10:09 ` Jan Beulich
2017-01-24 16:43 ` Wei Liu
2017-01-24 17:05 ` Ian Jackson
2017-01-24 17:18 ` Wei Liu
2017-01-24 17:22 ` Ian Jackson [this message]
2017-01-24 17:25 ` Andrew Cooper
2017-01-24 17:27 ` Wei Liu
2017-01-24 17:30 ` Ian Jackson
2017-01-24 17:37 ` Wei Liu
2017-01-24 17:46 ` Ian Jackson
2017-01-24 17:28 ` Wei Liu
2017-01-20 12:11 ` [PATCH 3/4] tools/fuzz: add AFL stub program for libefl fuzzer Wei Liu
2017-01-24 10:10 ` Jan Beulich
2017-01-20 12:11 ` [PATCH 4/4] tools/fuzz: add README.afl Wei Liu
2017-01-24 19:27 ` Andrew Cooper
2017-01-25 9:49 ` Wei Liu
2017-01-25 9:51 ` George Dunlap
2017-01-25 9:54 ` Wei Liu
2017-01-24 18:18 ` [PATCH 0/4] fuzz: basic AFL support Julien Grall
2017-01-24 18:56 ` Wei Liu
2017-01-24 19:00 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22663.36189.603393.162103@mariner.uk.xensource.com \
--to=ian.jackson@eu.citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.