[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow
From: |
Greg Kurz |
Subject: |
Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking |
Date: |
Mon, 12 Mar 2018 14:02:29 +0100 |
On Mon, 12 Mar 2018 07:12:52 -0500
Eric Blake <address@hidden> wrote:
> On 03/11/2018 03:12 PM, Nia Alarie wrote:
> > Signed-off-by: Nia Alarie <address@hidden>
> > ---
> > 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...
>
I wasn't aware of Dan's patch but I agree it would result in a nicer
change for 9p. This being said, tomorrow is soft freeze... is there
a chance Dan's patch reaches master anytime soon ?
- [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking, Nia Alarie, 2018/03/11
- Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking, Greg Kurz, 2018/03/12
- Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking, Eric Blake, 2018/03/12
- Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking,
Greg Kurz <=
- Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking, Daniel P . Berrangé, 2018/03/12
- Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking, Greg Kurz, 2018/03/12
- Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking, nee, 2018/03/13
- Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking, Stefan Hajnoczi, 2018/03/13
- Re: [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking, Greg Kurz, 2018/03/13