: ensure that index is within bounds in stir421x_patch_device()
PATCH 1/1 : ensure that index is within bounds in stir421x_patch_device()
Test whether the index is within bounds before testing the element.
Signed-off-by Roel Kluin <[email protected]>
--- drivers/net/irda/irda-usb.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/irda/irda-usb.c +3 -2
@@ -1124,8 +1124,9 @@ static int stir421x_patch_device(struct irda_usb_cb *self)* The actual image starts after the "STMP" keyword * so forward to the firmware header tag */ -for (i =0 ; (fw->data[i] !=STIR421X_PATCH_END_OF_HDR_TAG ) && - (i < fw->size); i++) ; +for (i =0 ; i < fw->size; i++) +if (fw->data[i] ==STIR421X_PATCH_END_OF_HDR_TAG ) +break ;/* here we check for the out of buffer case */ if ((STIR421X_PATCH_END_OF_HDR_TAG == fw->data[i]) && (i <STIR421X_PATCH_CODE_OFFSET )) {