diff mbox series

[f2fs-dev,v2] f2fs_io: Fix integer multiplication overflow error in fiemap

Message ID 20230523122720.1628122-1-zangyangyang1@xiaomi.com (mailing list archive)
State New
Headers show
Series [f2fs-dev,v2] f2fs_io: Fix integer multiplication overflow error in fiemap | expand

Commit Message

zangyangyang1 May 23, 2023, 12:27 p.m. UTC
When using fiemap to obtain the block address of files
larger than 2GB ((2147483647+1) bytes), an integer
multiplication overflow error will occur.
This issue is caused by the following code:
    start = atoi(argv[1]) * F2FS_BLKSIZE;
    length = atoi(argv[2]) * F2FS_BLKSIZE;

Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>
---
Changes since v1:
- Use type casting
---
 tools/f2fs_io/f2fs_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.40.1

#/******±¾Óʼþ¼°Æ丽¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈκÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØй¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#

Comments

Chao Yu May 24, 2023, 3:02 a.m. UTC | #1
On 2023/5/23 20:27, zangyangyang1 wrote:
> When using fiemap to obtain the block address of files
> larger than 2GB ((2147483647+1) bytes), an integer
> multiplication overflow error will occur.
> This issue is caused by the following code:
>      start = atoi(argv[1]) * F2FS_BLKSIZE;
>      length = atoi(argv[2]) * F2FS_BLKSIZE;
> 
> Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,
diff mbox series

Patch

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 5bc0baf..958d684 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -809,8 +809,8 @@  static void do_fiemap(int argc, char **argv, const struct cmd_desc *cmd)
        }

        memset(fm, 0, sizeof(struct fiemap));
-       start = atoi(argv[1]) * F2FS_BLKSIZE;
-       length = atoi(argv[2]) * F2FS_BLKSIZE;
+       start = (u64)atoi(argv[1]) * F2FS_BLKSIZE;
+       length = (u64)atoi(argv[2]) * F2FS_BLKSIZE;
        fm->fm_start = start;
        fm->fm_length = length;