From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Anton Moryakov <ant.v.moryakov@gmail.com>,
<linux-mtd@lists.infradead.org>
Subject: Re: [PATCH mtd-utils] ubi-utils: ubirsvol: Fix integer overflow in ubirsvol.c
Date: Tue, 10 Dec 2024 09:18:16 +0800 [thread overview]
Message-ID: <7d6a26b0-e40e-190e-059b-5459bf65d685@huawei.com> (raw)
In-Reply-To: <20241210000726.798402-1-ant.v.moryakov@gmail.com>
在 2024/12/10 8:07, Anton Moryakov 写道:
> Report of the static analyzer:
> The value of an arithmetic expression 'vol_info.leb_size * args.lebs' is a subject to overflow because its operands are not cast to a larger data type before performing arithmetic
>
> Corrections explained:
> The fix ensures values are checked before multiplication.
> Added casting vol_info.leb_size to long long
>
> Triggers found by static analyzer Svace.
>
> Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
>
> ---
> ubi-utils/ubirsvol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/ubi-utils/ubirsvol.c b/ubi-utils/ubirsvol.c
> index 0854abc..73d2f68 100644
> --- a/ubi-utils/ubirsvol.c
> +++ b/ubi-utils/ubirsvol.c
> @@ -231,7 +231,7 @@ int main(int argc, char * const argv[])
> }
>
> if (args.lebs != -1)
> - args.bytes = vol_info.leb_size * args.lebs;
> + args.bytes = (long long)vol_info.leb_size * args.lebs;
>
> err = ubi_rsvol(libubi, args.node, args.vol_id, args.bytes);
> if (err) {
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2024-12-10 1:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-10 0:07 [PATCH mtd-utils] ubi-utils: ubirsvol: Fix integer overflow in ubirsvol.c Anton Moryakov
2024-12-10 1:18 ` Zhihao Cheng [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-12-07 14:18 Anton Moryakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7d6a26b0-e40e-190e-059b-5459bf65d685@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=ant.v.moryakov@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.