On 07/17/2017 09:16 AM, Gerd Hoffmann wrote:
> Hi,
>
>> FWIW, most of these have been fixed in the meantime; the only
>> remaining
>> hack I had to add was:
>>
>> diff --git i/hw/usb/bus.c w/hw/usb/bus.c
>> index 5939b273b9..bce011058b 100644
>> --- i/hw/usb/bus.c
>> +++ w/hw/usb/bus.c
>> @@ -407,8 +407,9 @@ void usb_register_companion(const char
>> *masterbus,
>> USBPort *ports[],
>> void usb_port_location(USBPort *downstream, USBPort *upstream, int
>> portnr)
>> {
>> if (upstream) {
>> - snprintf(downstream->path, sizeof(downstream->path),
>> "%s.%d",
>> - upstream->path, portnr);
>> + int l = snprintf(downstream->path, sizeof(downstream->path),
>> "%s.%d",
>> + upstream->path, portnr);
>> + assert(l < sizeof(downstream->path));
>
> Approach looks ok to me.
>
> Maximum hub chain length is 5, number of ports hubs is limited too,
> you'll never need more that two digits for port numbers. So 2*5 plus 4
> connecting dots => 14 chars is the max strlen. path size is 16, so it
> will fit, including the terminating \0.Cool! With that text in the commit message and/or code comment, we can turn this from a hack into an actual patch, with no change in code. I'll go ahead and spin this as a formal patch. > > Trying things like "assert(portnr <= 99)" have no effect on the > possible string length calculated by gcc7. Perhaps a limitation that ought to be reported to the gcc folks. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
