All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] ALSA: hdsp: silence a sprinft() overflow warning
@ 2015-06-11 15:14 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2015-06-11 15:14 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Benoit Taine, alsa-devel, kernel-janitors, Bjorn Helgaas

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;
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [patch] ALSA: hdsp: silence a sprinft() overflow warning
@ 2015-06-11 15:14 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2015-06-11 15:14 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Benoit Taine, alsa-devel, kernel-janitors, Bjorn Helgaas

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;
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [patch] ALSA: hdsp: silence a sprinft() overflow warning
  2015-06-11 15:14 ` Dan Carpenter
@ 2015-08-21 11:25   ` Dan Carpenter
  -1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2015-08-21 11:25 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Benoit Taine, Bjorn Helgaas, alsa-devel, kernel-janitors

Ping?

regards,
dan carpenter

On Thu, Jun 11, 2015 at 06:14:34PM +0300, Dan Carpenter wrote:
> 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;
>  

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ALSA: hdsp: silence a sprinft() overflow warning
@ 2015-08-21 11:25   ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2015-08-21 11:25 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Benoit Taine, Bjorn Helgaas, alsa-devel, kernel-janitors

Ping?

regards,
dan carpenter

On Thu, Jun 11, 2015 at 06:14:34PM +0300, Dan Carpenter wrote:
> 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;
>  

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ALSA: hdsp: silence a sprinft() overflow warning
  2015-08-21 11:25   ` Dan Carpenter
@ 2015-08-21 12:15     ` Takashi Iwai
  -1 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2015-08-21 12:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jaroslav Kysela, Benoit Taine, Bjorn Helgaas, alsa-devel,
	kernel-janitors

On Fri, 21 Aug 2015 13:25:02 +0200,
Dan Carpenter wrote:
> 
> Ping?

I seem to have missed it.  Could you resubmit?


thanks,

Takashi

> 
> regards,
> dan carpenter
> 
> On Thu, Jun 11, 2015 at 06:14:34PM +0300, Dan Carpenter wrote:
> > 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;
> >  
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ALSA: hdsp: silence a sprinft() overflow warning
@ 2015-08-21 12:15     ` Takashi Iwai
  0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2015-08-21 12:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jaroslav Kysela, Benoit Taine, Bjorn Helgaas, alsa-devel,
	kernel-janitors

On Fri, 21 Aug 2015 13:25:02 +0200,
Dan Carpenter wrote:
> 
> Ping?

I seem to have missed it.  Could you resubmit?


thanks,

Takashi

> 
> regards,
> dan carpenter
> 
> On Thu, Jun 11, 2015 at 06:14:34PM +0300, Dan Carpenter wrote:
> > 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;
> >  
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [patch] ALSA: hdsp: silence a sprinft() overflow warning
  2015-08-21 12:15     ` Takashi Iwai
@ 2015-08-22  9:24       ` Dan Carpenter
  -1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2015-08-22  9:24 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Jaroslav Kysela, alsa-devel, kernel-janitors

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 468a95c..afb2dea 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;
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [patch] ALSA: hdsp: silence a sprinft() overflow warning
@ 2015-08-22  9:24       ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2015-08-22  9:24 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Jaroslav Kysela, alsa-devel, kernel-janitors

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 468a95c..afb2dea 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;
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [patch] ALSA: hdsp: silence a sprinft() overflow warning
  2015-08-22  9:24       ` Dan Carpenter
@ 2015-08-22  9:37         ` Takashi Iwai
  -1 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2015-08-22  9:37 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel, Jaroslav Kysela, kernel-janitors

On Sat, 22 Aug 2015 11:24:13 +0200,
Dan Carpenter wrote:
> 
> 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>

Applied, thanks.


Takashi

> 
> diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
> index 468a95c..afb2dea 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;
>  
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ALSA: hdsp: silence a sprinft() overflow warning
@ 2015-08-22  9:37         ` Takashi Iwai
  0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2015-08-22  9:37 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel, Jaroslav Kysela, kernel-janitors

On Sat, 22 Aug 2015 11:24:13 +0200,
Dan Carpenter wrote:
> 
> 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>

Applied, thanks.


Takashi

> 
> diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
> index 468a95c..afb2dea 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;
>  
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-08-22  9:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-11 15:14 [patch] ALSA: hdsp: silence a sprinft() overflow warning Dan Carpenter
2015-06-11 15:14 ` 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

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.