From: Greg Kurz <groug@kaod.org>
To: Nia Alarie <nia.alarie@gmail.com>
Cc: stefanha@gmail.com, jim@groklearning.com, qemu-devel@nongnu.org,
joel@jms.id.au
Subject: Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking
Date: Mon, 12 Mar 2018 14:16:57 +0100 [thread overview]
Message-ID: <20180312141657.1c896222@bahia.lan> (raw)
In-Reply-To: <20180312100146.132ad93a@bahia.lan>
On Mon, 12 Mar 2018 10:01:46 +0100
Greg Kurz <groug@kaod.org> wrote:
> On Sun, 11 Mar 2018 20:12:39 +0000
> Nia Alarie <nia.alarie@gmail.com> wrote:
>
> > Signed-off-by: Nia Alarie <nia.alarie@gmail.com>
> > ---
>
> Applied, thanks.
>
Following Eric's suggestion in another mail, let's give a chance for
the new qemu_strto*() helpers to reach master.
Also, FIDs are unsigned 32-bit integers, so we should use a qemu_strtou*()
variant.
> > hw/9pfs/9p.c | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > index 48fa48e720..64f3bb976c 100644
> > --- a/hw/9pfs/9p.c
> > +++ b/hw/9pfs/9p.c
> > @@ -15,6 +15,7 @@
> > #include <glib/gprintf.h>
> > #include "hw/virtio/virtio.h"
> > #include "qapi/error.h"
> > +#include "qemu/cutils.h"
> > #include "qemu/error-report.h"
> > #include "qemu/iov.h"
> > #include "qemu/sockets.h"
> > @@ -2213,8 +2214,15 @@ static void coroutine_fn v9fs_create(void *opaque)
> > }
> > v9fs_path_copy(&fidp->path, &path);
> > } 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) {
> > + err = -EINVAL;
> > + goto out;
> > + }
> > + ofidp = get_fid(pdu, (int32_t)ofid);
> > if (ofidp == NULL) {
> > err = -EINVAL;
> > goto out;
>
>
next prev parent reply other threads:[~2018-03-12 13:17 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 [this message]
2018-03-12 12:12 ` Eric Blake
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=20180312141657.1c896222@bahia.lan \
--to=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).