Commit 1d71d682 authored by Roel Kluin's avatar Roel Kluin Committed by Samuel Ortiz

irda: test index before read in stir421x_patch_device()

Test whether index exceeds fw->size before reading the element
Signed-off-by: default avatarRoel Kluin <roel.kluin@gmail.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 2fbd3da3
...@@ -1122,11 +1122,12 @@ static int stir421x_patch_device(struct irda_usb_cb *self) ...@@ -1122,11 +1122,12 @@ static int stir421x_patch_device(struct irda_usb_cb *self)
* The actual image starts after the "STMP" keyword * The actual image starts after the "STMP" keyword
* so forward to the firmware header tag * so forward to the firmware header tag
*/ */
for (i = 0; (fw->data[i] != STIR421X_PATCH_END_OF_HDR_TAG) for (i = 0; i < fw->size && fw->data[i] !=
&& (i < fw->size); i++) ; STIR421X_PATCH_END_OF_HDR_TAG; i++)
;
/* here we check for the out of buffer case */ /* here we check for the out of buffer case */
if ((STIR421X_PATCH_END_OF_HDR_TAG == fw->data[i]) if (i < STIR421X_PATCH_CODE_OFFSET && i < fw->size &&
&& (i < STIR421X_PATCH_CODE_OFFSET)) { STIR421X_PATCH_END_OF_HDR_TAG == fw->data[i]) {
if (!memcmp(fw->data + i + 1, STIR421X_PATCH_STMP_TAG, if (!memcmp(fw->data + i + 1, STIR421X_PATCH_STMP_TAG,
sizeof(STIR421X_PATCH_STMP_TAG) - 1)) { sizeof(STIR421X_PATCH_STMP_TAG) - 1)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment