]> git.ipfire.org Git - thirdparty/openwrt.git/commit
mtd: fis: fix buffer overflow from negative memset size 23550/head
authorAnna Kiri <bredcorn@gmail.com>
Tue, 26 May 2026 17:10:36 +0000 (19:10 +0200)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Fri, 17 Jul 2026 08:02:59 +0000 (10:02 +0200)
commitdd62e3af151d4a92aa8251148ec9b88fa558be73
treec93c0a0c32ab60317625eab896d9a18df011364f
parent938a43b52212634d1c62901cae97f5152c3d3926
mtd: fis: fix buffer overflow from negative memset size

In fis_remap(), when desc < last, the memset size is computed as
'tmp - end'. Since tmp is calculated as 'end - positive_value', tmp is
always less than end, making 'tmp - end' negative. When cast to size_t,
this wraps to a very large value, causing a massive buffer overflow.

Fix by swapping the operands to 'end - tmp' which correctly computes the
number of bytes to clear.

Signed-off-by: Anna Kiri <bredcorn@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23550
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
package/system/mtd/src/fis.c