openwrt/target/linux/generic/files/drivers/mtd/mtdsplit
Oldřich Jedlička 5e9aae9ef0 kernel: Fix off-by-one error in FIT mtd partition search.
This fixes off-by-one error introduced in commit dc76900021
("kernel: Correctly search for the FIT image in mtd partition.")

Function `mtd_read` starts reading at `offset` and
needs `hdr_len` number of bytes to be available. Suppose
the easiest case when `offset` is `0` and `hdr_len` equals
to `mtd->size` - the `for` loop will not be entered even
when enough bytes are available to be read.

Same happens for any non-zero `offset`, when `hdr_len` is
just enough bytes to be read until `mtd->size` is reached.
Imagine that for example `mtd->size=5`, `offset=4` and
`hdr_len=1`. Then `offset+hdr_len=5` and the check has to
be `offset+hdr_len <= mtd->size`, i.e. `5 <= 5`. The
check for `offset + hdr_len` value needs to be inclusive,
therefore use `<=`.

Fixes: dc76900021 ("kernel: Correctly search for the FIT image in mtd partition.")
Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
[adjusted commit ref, fixes tag]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
(cherry picked from commit e0ce80d42a)
2019-10-09 21:05:08 +02:00
..
Kconfig kernel: mtdsplit: Add support for D-link JBOOT 2018-02-11 16:02:52 +01:00
Makefile kernel: mtdsplit: Add support for D-link JBOOT 2018-02-11 16:02:52 +01:00
mtdsplit_brnimage.c kernel: update mtdsplit for linux 4.9 2017-02-03 12:35:44 +01:00
mtdsplit_eva.c kernel: add DT binding support to AVM EVA parser 2018-12-06 08:42:40 +01:00
mtdsplit_fit.c kernel: Fix off-by-one error in FIT mtd partition search. 2019-10-09 21:05:08 +02:00
mtdsplit_jimage.c kernel: drop unneeded LINUX_VERSION_CODE checks 2018-12-13 16:59:21 +01:00
mtdsplit_lzma.c kernel: add DT binding support to the LZMA and WRG parsers 2018-12-13 16:59:00 +01:00
mtdsplit_minor.c kernel: drop unneeded LINUX_VERSION_CODE checks 2018-12-13 16:59:21 +01:00
mtdsplit_seama.c kernel: drop unneeded LINUX_VERSION_CODE checks 2018-12-13 16:59:21 +01:00
mtdsplit_squashfs.c kernel: update mtdsplit for linux 4.9 2017-02-03 12:35:44 +01:00
mtdsplit_tplink.c kernel: drop unneeded LINUX_VERSION_CODE checks 2018-12-13 16:59:21 +01:00
mtdsplit_trx.c kernel: drop unneeded LINUX_VERSION_CODE checks 2018-12-13 16:59:21 +01:00
mtdsplit_uimage.c kernel: add DT binding support to the Edimax uImage parser 2019-01-19 12:51:04 +01:00
mtdsplit_wrgg.c kernel: mtdsplit: wrgg: Support big and little endian 2019-03-13 16:25:36 +01:00
mtdsplit.c treewide: replace nbd@openwrt.org with nbd@nbd.name 2016-06-07 08:58:42 +02:00
mtdsplit.h treewide: replace nbd@openwrt.org with nbd@nbd.name 2016-06-07 08:58:42 +02:00