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>
This commit is contained in:
parent
938a43b522
commit
dd62e3af15
1 changed files with 1 additions and 1 deletions
|
|
@ -215,7 +215,7 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
|
|||
memmove(desc, last, end - tmp);
|
||||
if (desc < last) {
|
||||
tmp = end - (last - desc) * sizeof(struct fis_image_desc);
|
||||
memset(tmp, 0xff, tmp - end);
|
||||
memset(tmp, 0xff, end - tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue