media: mceusb: Fix potential out-of-bounds shift
Subsystems (3)
PATCH 1/1 media: mceusb: Fix potential out-of-bounds shift
When processing a MCE_RSP_GETPORTSTATUS command, the bit index to set in ir->txports_cabled comes from response data, and isn't validated.
As ir->txports_cabled is a u8, nothing should be done if the bit index is greater than 7.
--- drivers/media/rc/mceusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/mceusb.c +1 -1
@@ -1169,7 +1169,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, u8 *buf_in)switch (subcmd) {/* the one and only 5-byte return value command */ case MCE_RSP_GETPORTSTATUS : -if (buf_in[5 ] ==0 ) +if (buf_in[5 ] ==0 && *hi <8 ) ir->txports_cabled |=1 << *hi;break ;
Signature · 1 line
2.29.2
Quoted 18 lines · James Reynolds
When processing a
MCE_RSP_GETPORTSTATUScommand, the bit index to set inir->txports_cabledcomes from response data, and isn't validated.As
ir->txports_cabledis a u8, nothing should be done if the bit index is greater than 7.--- drivers/media/rc/mceusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/rc/mceusb.c +0
-0
drivers/media/rc/mceusb.c static void mceusb_handle_command(struct mceusb_dev *ir, u8 *buf_in) · line 1173
Quoted 6 lines
drivers/media/rc/mceusb.c +1
-1@@ -1169,7 +1169,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, u8 *buf_in)switch (subcmd) {/* the one and only 5-byte return value command */ case MCE_RSP_GETPORTSTATUS : -if (buf_in[5 ] ==0 ) +if (buf_in[5 ] ==0 && *hi <8 ) ir->txports_cabled |=1 << *hi;
So *hi is a port number. I don't know of any devices that have more than 2 ports, so this is fine.
Reviewed-by Sean Young <[email protected]>
Thanks
Sean