Commit 8a463639 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Takashi Iwai

ALSA: als100: fix format string overflow warning

The compiler sees that the format string might overflow for the longname:

sound/isa/als100.c: In function 'snd_als100_pnp_detect':
sound/isa/als100.c:225:27: error: ', dma ' directive writing 6 bytes into a region of size between 0 and 64 [-Werror=format-overflow=]
   sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d",
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/isa/als100.c:225:3: note: 'sprintf' output between 24 and 113 bytes into a destination of size 80
   sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d",

Open-coding "shortname" here gets us below the limit, and using
snprintf() is a good idea too.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 610e1ae9
...@@ -222,15 +222,16 @@ static int snd_card_als100_probe(int dev, ...@@ -222,15 +222,16 @@ static int snd_card_als100_probe(int dev,
if (pid->driver_data == SB_HW_DT019X) { if (pid->driver_data == SB_HW_DT019X) {
strcpy(card->driver, "DT-019X"); strcpy(card->driver, "DT-019X");
strcpy(card->shortname, "Diamond Tech. DT-019X"); strcpy(card->shortname, "Diamond Tech. DT-019X");
sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", snprintf(card->longname, sizeof(card->longname),
card->shortname, chip->name, chip->port, "Diamond Tech. DT-019X, %s at 0x%lx, irq %d, dma %d",
irq[dev], dma8[dev]); chip->name, chip->port, irq[dev], dma8[dev]);
} else { } else {
strcpy(card->driver, "ALS100"); strcpy(card->driver, "ALS100");
strcpy(card->shortname, "Avance Logic ALS100"); strcpy(card->shortname, "Avance Logic ALS100");
sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", snprintf(card->longname, sizeof(card->longname),
card->shortname, chip->name, chip->port, "Avance Logic ALS100, %s at 0x%lx, irq %d, dma %d&%d",
irq[dev], dma8[dev], dma16[dev]); chip->name, chip->port, irq[dev], dma8[dev],
dma16[dev]);
} }
if ((error = snd_sb16dsp_pcm(chip, 0)) < 0) { if ((error = snd_sb16dsp_pcm(chip, 0)) < 0) {
......
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