[PATCH 1/1] fs: fat: avoid multiplication overflow
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Sun Jul 30 16:44:04 CEST 2023
The product of two 32 bit integers is a 32 bit integer. Hence
clustcount * bytesperclust may overflow on > 4 GiB devices.
Change the type of clustcount.
Fixes: cb8af8af5ba0 ("fs: fat: support write with non-zero offset")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
fs/fat/fat_write.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index e2a9913f80..289e7aa641 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -690,8 +690,8 @@ get_set_cluster(fsdata *mydata, __u32 clustnum, loff_t pos, __u8 *buffer,
static u8 *tmpbuf_cluster;
unsigned int bytesperclust = mydata->clust_size * mydata->sect_size;
__u32 startsect;
- loff_t wsize;
- int clustcount, i, ret;
+ loff_t clustcount, wsize;
+ int i, ret;
*gotsize = 0;
if (!size)
--
2.40.1
More information about the U-Boot
mailing list