Skip to content

Commit 3011e5e

Browse files
Dan Carpentermchehab
authored andcommitted
[media] firewire: firedtv-avc: potential buffer overflow
"program_info_length" is user controlled and can go up to 4095. The operand[] array has 509 bytes so we need to add a limit here to prevent buffer overflows. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
1 parent f2e323e commit 3011e5e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎drivers/media/firewire/firedtv-avc.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,10 @@ int avc_ca_pmt(struct firedtv *fdtv, char *msg, int length)
11571157
if (pmt_cmd_id != 1 && pmt_cmd_id != 4)
11581158
dev_err(fdtv->device,
11591159
"invalid pmt_cmd_id %d\n", pmt_cmd_id);
1160+
if (program_info_length > sizeof(c->operand) - write_pos) {
1161+
ret = -EINVAL;
1162+
goto out;
1163+
}
11601164

11611165
memcpy(&c->operand[write_pos], &msg[read_pos],
11621166
program_info_length);
@@ -1180,6 +1184,11 @@ int avc_ca_pmt(struct firedtv *fdtv, char *msg, int length)
11801184
dev_err(fdtv->device, "invalid pmt_cmd_id %d "
11811185
"at stream level\n", pmt_cmd_id);
11821186

1187+
if (es_info_length > sizeof(c->operand) - write_pos) {
1188+
ret = -EINVAL;
1189+
goto out;
1190+
}
1191+
11831192
memcpy(&c->operand[write_pos], &msg[read_pos],
11841193
es_info_length);
11851194
read_pos += es_info_length;

0 commit comments

Comments
 (0)