Re: [PATCH v2] virtio-mmio: Fix irq parsing in the command line

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

 



Pawel Moll <pawel.moll@xxxxxxx> writes:

> On 64-bit machines resource_size_t is a 64-bit value, while
> sscanf() format for this argument was defined as "%u". Fixed
> by using an intermediate local value of a known length.

Actually, on 32-bit machines, too (eg. x86 with PAE).  Otherwise we'd
just change it to %lu.

> +	/* Get "@<base>:<irq>[:<id>]" chunks */
>  	processed = sscanf(str, "@%lli:%u%n:%d%n",
> -			&base, &resources[1].start, &consumed,
> +			&base, &irq, &consumed,
>  			&vm_cmdline_id, &consumed);
>  
> +	/*
> +	 * sscanf() processes 3 chunks if "<id>" is given, 2 if not;
> +	 * also there must be no extra characters after the last
> +	 * chunk, so str[consumed] should be '\0'
> +	 */
>  	if (processed < 2 || processed > 3 || str[consumed])
>  		return -EINVAL;

I would drop the > 3 case.  It's unnecessary, and you're assuming
consumed doesn't add to the count, which may be true but is a documented
sscanf weirdness so I don't like to rely on it.

Thanks,
Rusty.
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux