Skip to content

Commit

Permalink
[media] siano: Fix array boundary at smscore_translate_msg()
Browse files Browse the repository at this point in the history
As reported by Dan Carpenter:
	FYI, there are new smatch warnings show up in

	tree:   git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next master
	head:   da17d7bda957ae4697b6abc0793f74fb9b50b58f
	commit: 4c3bdb5 [media] siano: better debug send/receive messages

	drivers/media/common/siano/smscoreapi.c:396 smscore_translate_msg() error: buffer overflow 'siano_msgs' 401 <= 401

While it is almost impossible for this error to happen in
practice, as it would require the siano's firmware to return
an special invalid answer to a message request, fixing it
is trivial. So, let's do it.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab committed Apr 4, 2013
1 parent f9f11df commit 53faa68
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/media/common/siano/smscoreapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ char *smscore_translate_msg(enum msg_types msgtype)
int i = msgtype - MSG_TYPE_BASE_VAL;
char *msg;

if (i < 0 || i > ARRAY_SIZE(siano_msgs))
if (i < 0 || i >= ARRAY_SIZE(siano_msgs))
return "Unknown msg type";

msg = siano_msgs[i];
Expand Down

0 comments on commit 53faa68

Please sign in to comment.