qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/9] hw/core/qdev-properties: Use qemu_strtoul() in set_pci_h


From: Richard Henderson
Subject: Re: [PATCH 2/9] hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr()
Date: Sun, 15 Mar 2020 14:43:01 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 3/13/20 11:46 AM, Philippe Mathieu-Daudé wrote:
> Replace strtoul() by qemu_strtoul() so checkpatch.pl won't complain
> if we move this code later.
...

>      p = str;
> -    val = strtoul(p, &e, 16);
> -    if (e == p || *e != ':') {
> +    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0xffff || e == p) {
> +        goto inval;
> +    }
> +    if (*e != ':') {

You can drop the e == p test.  That's done in check_strtox_error, called by
qemu_strtoul.  Same for the other 2 instances.

The range check looks wrong, as we have not yet decided if this element is
"dom" or "bus".

> -    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7) {
> +    if (bus > 0xff) {

I think it makes sense to leave this line unchanged.  Increase the slot and
func local variables increased to unsigned long so that the range check isn't
truncated.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]