Skip to content

Commit ef21e17

Browse files
jazzguitar81tiwai
authored andcommitted
ALSA: Use scnprintf() instead of snprintf() for show
The show() method should use scnprintf() not snprintf() because snprintf() may returns a value that exceeds its second argument. Signed-off-by: Jaejoong Kim <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 248a380 commit ef21e17

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/core/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ card_id_show_attr(struct device *dev,
670670
struct device_attribute *attr, char *buf)
671671
{
672672
struct snd_card *card = container_of(dev, struct snd_card, card_dev);
673-
return snprintf(buf, PAGE_SIZE, "%s\n", card->id);
673+
return scnprintf(buf, PAGE_SIZE, "%s\n", card->id);
674674
}
675675

676676
static ssize_t
@@ -710,7 +710,7 @@ card_number_show_attr(struct device *dev,
710710
struct device_attribute *attr, char *buf)
711711
{
712712
struct snd_card *card = container_of(dev, struct snd_card, card_dev);
713-
return snprintf(buf, PAGE_SIZE, "%i\n", card->number);
713+
return scnprintf(buf, PAGE_SIZE, "%i\n", card->number);
714714
}
715715

716716
static DEVICE_ATTR(number, S_IRUGO, card_number_show_attr, NULL);

0 commit comments

Comments
 (0)