Skip to content

Commit

Permalink
ALSA: Use scnprintf() instead of snprintf() for show
Browse files Browse the repository at this point in the history
The show() method should use scnprintf() not snprintf() because snprintf()
may returns a value that exceeds its second argument.

Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Jaejoong Kim authored and Takashi Iwai committed Feb 27, 2018
1 parent 248a380 commit ef21e17
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sound/core/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ card_id_show_attr(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct snd_card *card = container_of(dev, struct snd_card, card_dev);
return snprintf(buf, PAGE_SIZE, "%s\n", card->id);
return scnprintf(buf, PAGE_SIZE, "%s\n", card->id);
}

static ssize_t
Expand Down Expand Up @@ -710,7 +710,7 @@ card_number_show_attr(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct snd_card *card = container_of(dev, struct snd_card, card_dev);
return snprintf(buf, PAGE_SIZE, "%i\n", card->number);
return scnprintf(buf, PAGE_SIZE, "%i\n", card->number);
}

static DEVICE_ATTR(number, S_IRUGO, card_number_show_attr, NULL);
Expand Down

0 comments on commit ef21e17

Please sign in to comment.