ALSA: opti9xx: fix format string overflow warning
authorArnd Bergmann <arnd@arndb.de>
Tue, 18 Jul 2017 11:48:07 +0000 (13:48 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 18 Jul 2017 15:53:56 +0000 (17:53 +0200)
commit24d220773139ae03fc7bda692c5f6335ea457059
treebd39c79fd79130efdce0493a65a44d89eaeac002
parent003d3e70dbebe9d99387f2eeda405b1950b808f2
ALSA: opti9xx: fix format string overflow warning

We pass a long name from "codec->pcm->name" into the longname
string of the same length:

sound/isa/opti9xx/miro.c: In function 'snd_miro_probe':
sound/isa/opti9xx/miro.c:1356:39: error: '%s' directive writing up to 79 bytes into a region of size between 35 and 72 [-Werror=format-overflow=]
  sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",
                                       ^~
sound/isa/opti9xx/miro.c:1356:26: note: using the range [0, 4294967295] for directive argument
  sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/isa/opti9xx/miro.c:1356:2: note: 'sprintf' output between 32 and 185 bytes into a destination of size 80
  sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",

There is no easy way to avoid the theoretical overflow in this case,
but using snprintf() will turn it into a harmless truncation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/isa/opti9xx/miro.c
sound/isa/opti9xx/opti92x-ad1848.c