瀏覽代碼

media: v4l2-tpg: array index could become negative

commit e5f71a27fa12c1a1b02ad478a568e76260f1815e upstream.

text[s] is a signed char, so using that as index into the font8x16 array
can result in negative indices. Cast it to u8 to be safe.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: syzbot+ccf0a61ed12f2a7313ee@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>      # for v4.7 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Hans Verkuil 7 年之前
父節點
當前提交
47af3cecd5
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/media/common/v4l2-tpg/v4l2-tpg-core.c

+ 1 - 1
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c

@@ -1738,7 +1738,7 @@ typedef struct { u16 __; u8 _; } __packed x24;
 		unsigned s;	\
 		unsigned s;	\
 	\
 	\
 		for (s = 0; s < len; s++) {	\
 		for (s = 0; s < len; s++) {	\
-			u8 chr = font8x16[text[s] * 16 + line];	\
+			u8 chr = font8x16[(u8)text[s] * 16 + line];	\
 	\
 	\
 			if (hdiv == 2 && tpg->hflip) { \
 			if (hdiv == 2 && tpg->hflip) { \
 				pos[3] = (chr & (0x01 << 6) ? fg : bg);	\
 				pos[3] = (chr & (0x01 << 6) ? fg : bg);	\