diff mbox

ALSA: firewire-tascam: off by one in identify_model()

Message ID 20151015181828.GC3163@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Oct. 15, 2015, 6:18 p.m. UTC
In the original code, we potentially put a NUL character in model[8] and
it caused a static checker warning.  We can put the NUL in model[7]
instead.

Fixes: 53b3ffee7885 ('ALSA: firewire-tascam: change device probing processing')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Takashi Iwai Oct. 17, 2015, 10:11 a.m. UTC | #1
On Thu, 15 Oct 2015 20:18:29 +0200,
Dan Carpenter wrote:
> 
> In the original code, we potentially put a NUL character in model[8] and
> it caused a static checker warning.  We can put the NUL in model[7]
> instead.

I guess it's better to expand model[] to 9 bytes instead.  The logic
is to retrieve the string from the config rom, and it's up to 8
letters.


thanks,

Takashi

> 
> Fixes: 53b3ffee7885 ('ALSA: firewire-tascam: change device probing processing')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
> index c6747a4..6ef2bcc 100644
> --- a/sound/firewire/tascam/tascam.c
> +++ b/sound/firewire/tascam/tascam.c
> @@ -51,7 +51,7 @@ static int identify_model(struct snd_tscm *tscm)
>  	}
>  
>  	/* Pick up model name from certain addresses. */
> -	for (i = 0; i < 8; i++) {
> +	for (i = 0; i < 7; i++) {
>  		c = config_rom[28 + i / 4] >> (24 - 8 * (i % 4));
>  		if (c == '\0')
>  			break;
>
Dan Carpenter Oct. 17, 2015, 12:02 p.m. UTC | #2
On Sat, Oct 17, 2015 at 12:11:58PM +0200, Takashi Iwai wrote:
> On Thu, 15 Oct 2015 20:18:29 +0200,
> Dan Carpenter wrote:
> > 
> > In the original code, we potentially put a NUL character in model[8] and
> > it caused a static checker warning.  We can put the NUL in model[7]
> > instead.
> 
> I guess it's better to expand model[] to 9 bytes instead.  The logic
> is to retrieve the string from the config rom, and it's up to 8
> letters.

Ok.  I will resend.

regards,
dan carpenter
Takashi Sakamoto Oct. 18, 2015, 1 a.m. UTC | #3
On Oct 17 2015 21:02, Dan Carpenter wrote:
> On Sat, Oct 17, 2015 at 12:11:58PM +0200, Takashi Iwai wrote:
>> On Thu, 15 Oct 2015 20:18:29 +0200,
>> Dan Carpenter wrote:
>>>
>>> In the original code, we potentially put a NUL character in model[8] and
>>> it caused a static checker warning.  We can put the NUL in model[7]
>>> instead.
>>
>> I guess it's better to expand model[] to 9 bytes instead.  The logic
>> is to retrieve the string from the config rom, and it's up to 8
>> letters.
> 
> Ok.  I will resend.

I think this idea is better, too.


Thanks

Takashi Sakamoto
diff mbox

Patch

diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
index c6747a4..6ef2bcc 100644
--- a/sound/firewire/tascam/tascam.c
+++ b/sound/firewire/tascam/tascam.c
@@ -51,7 +51,7 @@  static int identify_model(struct snd_tscm *tscm)
 	}
 
 	/* Pick up model name from certain addresses. */
-	for (i = 0; i < 8; i++) {
+	for (i = 0; i < 7; i++) {
 		c = config_rom[28 + i / 4] >> (24 - 8 * (i % 4));
 		if (c == '\0')
 			break;