summaryrefslogtreecommitdiff
path: root/drivers/staging/media/av7110/av7110_av.c
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2023-03-07 13:00:23 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-03-20 00:57:50 +0300
commiteed9496a0501357aa326ddd6b71408189ed872eb (patch)
treed4124ee8573dd2f1e32cfd0c24309e6109a98383 /drivers/staging/media/av7110/av7110_av.c
parent4ae47770d57bff0193fbbf48d56c18759cad5f6e (diff)
downloadlinux-eed9496a0501357aa326ddd6b71408189ed872eb.tar.xz
media: av7110: prevent underflow in write_ts_to_decoder()
The buf[4] value comes from the user via ts_play(). It is a value in the u8 range. The final length we pass to av7110_ipack_instant_repack() is "len - (buf[4] + 1) - 4" so add a check to ensure that the length is not negative. It's not clear that passing a negative len value does anything bad necessarily, but it's not best practice. With the new bounds checking the "if (!len)" condition is no longer possible or required so remove that. Fixes: fd46d16d602a ("V4L/DVB (11759): dvb-ttpci: Add TS replay capability") Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/staging/media/av7110/av7110_av.c')
-rw-r--r--drivers/staging/media/av7110/av7110_av.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/media/av7110/av7110_av.c b/drivers/staging/media/av7110/av7110_av.c
index 0bf513c26b6b..a5c5bebad306 100644
--- a/drivers/staging/media/av7110/av7110_av.c
+++ b/drivers/staging/media/av7110/av7110_av.c
@@ -823,10 +823,10 @@ static int write_ts_to_decoder(struct av7110 *av7110, int type, const u8 *buf, s
av7110_ipack_flush(ipack);
if (buf[3] & ADAPT_FIELD) {
+ if (buf[4] > len - 1 - 4)
+ return 0;
len -= buf[4] + 1;
buf += buf[4] + 1;
- if (!len)
- return 0;
}
av7110_ipack_instant_repack(buf + 4, len - 4, ipack);