From: Eric Blake <eblake@redhat.com>
To: Nia Alarie <nia.alarie@gmail.com>, qemu-devel@nongnu.org
Cc: stefanha@gmail.com, jim@groklearning.com, groug@kaod.org,
joel@jms.id.au, "Daniel P. Berrange" <berrange@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking
Date: Mon, 12 Mar 2018 07:12:52 -0500 [thread overview]
Message-ID: <486e1b60-e453-c3de-040b-8b2951ddf3a5@redhat.com> (raw)
In-Reply-To: <20180311201239.25506-1-nia.alarie@gmail.com>
On 03/11/2018 03:12 PM, Nia Alarie wrote:
> Signed-off-by: Nia Alarie <nia.alarie@gmail.com>
> ---
> hw/9pfs/9p.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> } else if (perm & P9_STAT_MODE_LINK) {
> - int32_t ofid = atoi(extension.data);
> - V9fsFidState *ofidp = get_fid(pdu, ofid);
> + long ofid;
> + V9fsFidState *ofidp;
> +
> + if (qemu_strtol(extension.data, NULL, 10, &ofid) ||
> + ofid > INT32_MAX || ofid < INT32_MIN) {
Dan has a pending patch that will add qemu_strtoi, which might be a
nicer fit for this situation:
https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg00952.html
int32_t is not necessarily int, but all platforms that compile qemu have
'int32_t' and 'int' both at 32 bits, so it's simpler to change to 'int
ofid' and use Dan's function than it is to parse to long and then do
bounds checking. Except that Dan still needs to post an updated version
of his patch...
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2018-03-12 12:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-11 20:12 [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking Nia Alarie
2018-03-12 9:01 ` Greg Kurz
2018-03-12 13:16 ` Greg Kurz
2018-03-12 12:12 ` Eric Blake [this message]
2018-03-12 13:02 ` Greg Kurz
2018-03-12 13:08 ` Daniel P. Berrangé
2018-03-12 13:21 ` Greg Kurz
2018-03-13 15:25 ` nee
2018-03-13 15:52 ` Stefan Hajnoczi
2018-03-13 16:28 ` Greg Kurz
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=486e1b60-e453-c3de-040b-8b2951ddf3a5@redhat.com \
--to=eblake@redhat.com \
--cc=berrange@redhat.com \
--cc=groug@kaod.org \
--cc=jim@groklearning.com \
--cc=joel@jms.id.au \
--cc=nia.alarie@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).