When verifying the validity of IHEX file we need to make sure that zero-length record we found is located at the end of the file. Not doing that could result in an invalid file with a bogus zero-length in the middle short-circuiting the check and being reported as valid.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -49,7 +49,7 @@ static inline int ihex_validate_fw(const struct firmware *fw) · 48 unmodified lines | |||
| 49 | 49 | ||
| 50 | for (; rec <= end; rec = __ihex_next_binrec(rec)) { | 50 | for (; rec <= end; rec = __ihex_next_binrec(rec)) { |
| 51 | /* Zero length marks end of records */ | 51 | /* Zero length marks end of records */ |
| 52 | if (!be16_to_cpu(rec->len)) | 52 | if (rec == end && !be16_to_cpu(rec->len)) |
| 53 | return 0; | 53 | return 0; |
| 54 | } | 54 | } |
| 55 | return -EINVAL; | 55 | return -EINVAL; |