aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Moryakov <ant.v.moryakov@gmail.com>2024-12-10 03:07:26 +0300
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-12-17 14:34:18 +0100
commit36d1ba9ba75e45da5ff049f4a4bec4ea576a9689 (patch)
tree5566e7976a8fe289504d266cc6084d2267a37d3a
parent2764911eb37dfb302d44bb5b2d5984d662b40c27 (diff)
ubi-utils: ubirsvol: Fix integer overflow in ubirsvol.c
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> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--ubi-utils/ubirsvol.c2
1 files changed, 1 insertions, 1 deletions
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) {