]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fs/erofs: fix an overflow issue of unmapped extents
authorJianan Huang <jnhuang95@gmail.com>
Wed, 5 Jun 2024 14:05:54 +0000 (14:05 +0000)
committerTom Rini <trini@konsulko.com>
Fri, 14 Jun 2024 18:59:06 +0000 (12:59 -0600)
Here the size should be `length - skip`, otherwise it could cause
the destination buffer overflow.

Reported-by: jianqiang wang <wjq.sec@gmail.com>
Fixes: 65cb73057b65 ("fs/erofs: add lz4 decompression support")
Signed-off-by: Jianan Huang <jnhuang95@gmail.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/data.c

index f4b21d7917a34d51b720c7ea82c0b7f557d6301f..95b609d8ea829b9abf86dc3f001882c7d059541a 100644 (file)
@@ -313,7 +313,7 @@ static int z_erofs_read_data(struct erofs_inode *inode, char *buffer,
                }
 
                if (!(map.m_flags & EROFS_MAP_MAPPED)) {
-                       memset(buffer + end - offset, 0, length);
+                       memset(buffer + end - offset, 0, length - skip);
                        end = map.m_la;
                        continue;
                }