47 lines
1.4 KiB
Diff
47 lines
1.4 KiB
Diff
From acd05d6e8066f775474cbcf00b85b4743efe896e Mon Sep 17 00:00:00 2001
|
|
From: Thomas Haller <thaller@redhat.com>
|
|
Date: Mon, 4 Dec 2023 12:13:40 +0100
|
|
Subject: [PATCH] route/tc: avoid integer overflow in rtnl_tc_calc_cell_log()
|
|
|
|
Coverity doesn't like this. Workaround.
|
|
|
|
Error: CPPCHECK_WARNING (CWE-190): [#def97]
|
|
libnl-3.8.0/lib/route/tc.c:681: error[integerOverflow]: Signed integer overflow for expression '1<<i'.
|
|
# 679|
|
|
# 680| for (i = 0; i < 32; i++)
|
|
# 681|-> if ((1 << i) == cell_size)
|
|
# 682| return i;
|
|
# 683|
|
|
|
|
Conflict:NA
|
|
Reference:https://github.com/thom311/libnl/commit/acd05d6e8066f775474cbcf00b85b4743efe896e
|
|
|
|
---
|
|
lib/route/tc.c | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/lib/route/tc.c b/lib/route/tc.c
|
|
index a06a478..764b7f7 100644
|
|
--- a/lib/route/tc.c
|
|
+++ b/lib/route/tc.c
|
|
@@ -666,14 +666,14 @@ int rtnl_tc_calc_bufsize(int txtime, int rate)
|
|
/**
|
|
* Calculate the binary logarithm for a specific cell size
|
|
* @arg cell_size Size of cell, must be a power of two.
|
|
- * @return Binary logirhtm of cell size or a negative error code.
|
|
+ * @return Binary logarithm of cell size or a negative error code.
|
|
*/
|
|
int rtnl_tc_calc_cell_log(int cell_size)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < 32; i++)
|
|
- if ((1 << i) == cell_size)
|
|
+ if ((((uint32_t)1u) << i) == cell_size)
|
|
return i;
|
|
|
|
return -NLE_INVAL;
|
|
--
|
|
2.33.0
|
|
|