From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>, Benoit Taine <benoit.taine@lip6.fr>,
alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
Bjorn Helgaas <bhelgaas@google.com>
Subject: [patch] ALSA: hdsp: silence a sprinft() overflow warning
Date: Thu, 11 Jun 2015 18:14:34 +0300 [thread overview]
Message-ID: <20150611151434.GE12192@mwanda> (raw)
card->shortname is a 32 char string so the sprintf() can theoretically
overflow. snd_rawmidi_new() can accept strings up to 64 bytes long.
I have made the temporay buf[] array 40 bytes long and changed the
sprintf() to snprintf().
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index c19e021..c1fe1d3 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -1526,7 +1526,7 @@ static struct snd_rawmidi_ops snd_hdsp_midi_input =
static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id)
{
- char buf[32];
+ char buf[40];
hdsp->midi[id].id = id;
hdsp->midi[id].rmidi = NULL;
@@ -1537,7 +1537,7 @@ static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int i
hdsp->midi[id].pending = 0;
spin_lock_init (&hdsp->midi[id].lock);
- sprintf (buf, "%s MIDI %d", card->shortname, id+1);
+ snprintf(buf, sizeof(buf), "%s MIDI %d", card->shortname, id + 1);
if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0)
return -1;
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>, Benoit Taine <benoit.taine@lip6.fr>,
alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
Bjorn Helgaas <bhelgaas@google.com>
Subject: [patch] ALSA: hdsp: silence a sprinft() overflow warning
Date: Thu, 11 Jun 2015 15:14:34 +0000 [thread overview]
Message-ID: <20150611151434.GE12192@mwanda> (raw)
card->shortname is a 32 char string so the sprintf() can theoretically
overflow. snd_rawmidi_new() can accept strings up to 64 bytes long.
I have made the temporay buf[] array 40 bytes long and changed the
sprintf() to snprintf().
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index c19e021..c1fe1d3 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -1526,7 +1526,7 @@ static struct snd_rawmidi_ops snd_hdsp_midi_input
static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id)
{
- char buf[32];
+ char buf[40];
hdsp->midi[id].id = id;
hdsp->midi[id].rmidi = NULL;
@@ -1537,7 +1537,7 @@ static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int i
hdsp->midi[id].pending = 0;
spin_lock_init (&hdsp->midi[id].lock);
- sprintf (buf, "%s MIDI %d", card->shortname, id+1);
+ snprintf(buf, sizeof(buf), "%s MIDI %d", card->shortname, id + 1);
if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0)
return -1;
next reply other threads:[~2015-06-11 15:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-11 15:14 Dan Carpenter [this message]
2015-06-11 15:14 ` [patch] ALSA: hdsp: silence a sprinft() overflow warning Dan Carpenter
2015-08-21 11:25 ` Dan Carpenter
2015-08-21 11:25 ` Dan Carpenter
2015-08-21 12:15 ` Takashi Iwai
2015-08-21 12:15 ` Takashi Iwai
2015-08-22 9:24 ` Dan Carpenter
2015-08-22 9:24 ` Dan Carpenter
2015-08-22 9:37 ` Takashi Iwai
2015-08-22 9:37 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150611151434.GE12192@mwanda \
--to=dan.carpenter@oracle.com \
--cc=alsa-devel@alsa-project.org \
--cc=benoit.taine@lip6.fr \
--cc=bhelgaas@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.