Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ihex: Check if zero-length record is at the end of the blob

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.

Cc: Chris Healy <cphealy@gmail.com>
Cc: Kyle McMartin <kyle@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andrey Smirnov and committed by
Greg Kroah-Hartman
5158c36e 8092e792

+1 -1
+1 -1
include/linux/ihex.h
··· 49 49 50 50 for (; rec <= end; rec = __ihex_next_binrec(rec)) { 51 51 /* Zero length marks end of records */ 52 - if (!be16_to_cpu(rec->len)) 52 + if (rec == end && !be16_to_cpu(rec->len)) 53 53 return 0; 54 54 } 55 55 return -EINVAL;