Skip to contentSkip to conversation

: ensure that index is within bounds in stir421x_patch_device()

PATCH New Roel Kluin 1 participant 1 message Dec 14, 2009 Network drivers

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 : ensure that index is within bounds in stir421x_patch_device()

Test whether the index is within bounds before testing the element.

---
 drivers/net/irda/irda-usb.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/irda/irda-usb.c +3 -2
index e8e33bb..1b0bd32 100644
@@ -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)) {