Commit 3b06dbbeadb6488cd00999b61b080bb6f0218503
Committed by
Samuel Ortiz
1 parent
f8cba16cad
Exists in
master
and in
7 other branches
irda: Test index before read in stir421x_patch_device()
Test whether index exceeds fw->size before reading the element Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Samuel Ortiz <samuel@sortiz.org>
Showing 1 changed file with 4 additions and 4 deletions Side-by-side Diff
drivers/net/irda/irda-usb.c
... | ... | @@ -1124,11 +1124,11 @@ |
1124 | 1124 | * The actual image starts after the "STMP" keyword |
1125 | 1125 | * so forward to the firmware header tag |
1126 | 1126 | */ |
1127 | - for (i = 0; (fw->data[i] != STIR421X_PATCH_END_OF_HDR_TAG) && | |
1128 | - (i < fw->size); i++) ; | |
1127 | + for (i = 0; i < fw->size && fw->data[i] != | |
1128 | + STIR421X_PATCH_END_OF_HDR_TAG; i++) ; | |
1129 | 1129 | /* here we check for the out of buffer case */ |
1130 | - if ((STIR421X_PATCH_END_OF_HDR_TAG == fw->data[i]) && | |
1131 | - (i < STIR421X_PATCH_CODE_OFFSET)) { | |
1130 | + if (i < STIR421X_PATCH_CODE_OFFSET && i < fw->size && | |
1131 | + STIR421X_PATCH_END_OF_HDR_TAG == fw->data[i]) { | |
1132 | 1132 | if (!memcmp(fw->data + i + 1, STIR421X_PATCH_STMP_TAG, |
1133 | 1133 | sizeof(STIR421X_PATCH_STMP_TAG) - 1)) { |
1134 | 1134 |