Commit 76ef7fdf authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update - Jaroslav Kysela <perex@suse.cz>

USB generic driver
Clemens Ladisch <clemens@ladisch.de>
- fix buffer overflow (with 0x prefix, component would need 17
  chars)
- rewrite shortname logic
- include product name in longname even if card doesn't have a quirk
parent 332e6b18
......@@ -2738,23 +2738,21 @@ static int snd_usb_audio_create(snd_card_t *card, struct usb_device *dev,
}
strcpy(card->driver, "USB-Audio");
sprintf(component, "USB%#04x:%#04x",
sprintf(component, "USB%04x:%04x",
dev->descriptor.idVendor, dev->descriptor.idProduct);
snd_component_add(card, component);
/* retrieve the device string as shortname */
if (quirk && quirk->product_name) {
len = strlcpy(card->shortname, quirk->product_name, sizeof(card->shortname));
strlcpy(card->shortname, quirk->product_name, sizeof(card->shortname));
} else {
if (dev->descriptor.iProduct)
len = usb_string(dev, dev->descriptor.iProduct,
card->shortname, sizeof(card->shortname));
else
len = 0;
}
if (len <= 0) {
sprintf(card->shortname, "USB Device %#04x:%#04x",
dev->descriptor.idVendor, dev->descriptor.idProduct);
if (!dev->descriptor.iProduct ||
usb_string(dev, dev->descriptor.iProduct,
card->shortname, sizeof(card->shortname)) <= 0) {
/* no name available from anywhere, so use ID */
sprintf(card->shortname, "USB Device %#04x:%#04x",
dev->descriptor.idVendor, dev->descriptor.idProduct);
}
}
/* retrieve the vendor and device strings as longname */
......@@ -2766,14 +2764,12 @@ static int snd_usb_audio_create(snd_card_t *card, struct usb_device *dev,
card->longname, sizeof(card->longname));
else
len = 0;
/* we don't really care if there isn't any vendor string */
}
if (len > 0)
strlcat(card->longname, " ", sizeof(card->longname));
len = strlen(card->longname);
if (quirk && quirk->product_name)
strlcat(card->longname, quirk->product_name, sizeof(card->longname));
strlcat(card->longname, card->shortname, sizeof(card->longname));
len = strlcat(card->longname, " at ", sizeof(card->longname));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment