iproute/backport-tc_util-detect-overflow-in-get_size.patch
2023-12-28 20:08:02 +08:00

45 lines
1.1 KiB
Diff

From e07c57e94e27d2f15bfb9de4db7ca3ab9d9368ed Mon Sep 17 00:00:00 2001
From: Odin Ugedal <odin@ugedal.com>
Date: Thu, 16 Apr 2020 16:08:14 +0200
Subject: tc_util: detect overflow in get_size
This detects overflow during parsing of value using get_size:
eg. running:
$ tc qdisc add dev lo root cake memlimit 11gb
currently gives a memlimit of "3072Mb", while with this patch it errors
with 'illegal value for "memlimit": "11gb"', since memlinit is an
unsigned integer.
Signed-off-by: Odin Ugedal <odin@ugedal.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict:NA
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=e07c57e94e27d2f15bfb9de4db7ca3ab9d9368ed
---
tc/tc_util.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 5f13d729b..68938fb0c 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -385,6 +385,11 @@ int get_size(unsigned int *size, const char *str)
}
*size = sz;
+
+ /* detect if an overflow happened */
+ if (*size != floor(sz))
+ return -1;
+
return 0;
}
--
cgit 1.2.3-korg