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,24 +2738,22 @@ static int snd_usb_audio_create(snd_card_t *card, struct usb_device *dev, ...@@ -2738,24 +2738,22 @@ static int snd_usb_audio_create(snd_card_t *card, struct usb_device *dev,
} }
strcpy(card->driver, "USB-Audio"); strcpy(card->driver, "USB-Audio");
sprintf(component, "USB%#04x:%#04x", sprintf(component, "USB%04x:%04x",
dev->descriptor.idVendor, dev->descriptor.idProduct); dev->descriptor.idVendor, dev->descriptor.idProduct);
snd_component_add(card, component); snd_component_add(card, component);
/* retrieve the device string as shortname */ /* retrieve the device string as shortname */
if (quirk && quirk->product_name) { 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 { } else {
if (dev->descriptor.iProduct) if (!dev->descriptor.iProduct ||
len = usb_string(dev, dev->descriptor.iProduct, usb_string(dev, dev->descriptor.iProduct,
card->shortname, sizeof(card->shortname)); card->shortname, sizeof(card->shortname)) <= 0) {
else /* no name available from anywhere, so use ID */
len = 0;
}
if (len <= 0) {
sprintf(card->shortname, "USB Device %#04x:%#04x", sprintf(card->shortname, "USB Device %#04x:%#04x",
dev->descriptor.idVendor, dev->descriptor.idProduct); dev->descriptor.idVendor, dev->descriptor.idProduct);
} }
}
/* retrieve the vendor and device strings as longname */ /* retrieve the vendor and device strings as longname */
if (quirk && quirk->vendor_name) { if (quirk && quirk->vendor_name) {
...@@ -2766,14 +2764,12 @@ static int snd_usb_audio_create(snd_card_t *card, struct usb_device *dev, ...@@ -2766,14 +2764,12 @@ static int snd_usb_audio_create(snd_card_t *card, struct usb_device *dev,
card->longname, sizeof(card->longname)); card->longname, sizeof(card->longname));
else else
len = 0; len = 0;
/* we don't really care if there isn't any vendor string */
} }
if (len > 0) if (len > 0)
strlcat(card->longname, " ", sizeof(card->longname)); strlcat(card->longname, " ", sizeof(card->longname));
len = strlen(card->longname); strlcat(card->longname, card->shortname, sizeof(card->longname));
if (quirk && quirk->product_name)
strlcat(card->longname, quirk->product_name, sizeof(card->longname));
len = strlcat(card->longname, " at ", 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