get_tc_classid stores strtoul straight into __u32 on the no-colon path, so nine hex digits wrap: "123456789" arrives as 23456789. Refuse past 32 bits, checking errno so strtoul saturation cannot pass as 0xFFFFFFFF on 32-bit builds. Fixes: aba5acdfdb34 ("(Logical change 1.3)") Signed-off-by: Andrii Tereshchenko --- flower classid 123456789: was sent as 23456789, now Illegal "classid". tc/tc_util.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tc/tc_util.c b/tc/tc_util.c index 27e64d0e..50de3a7f 100644 --- a/tc/tc_util.c +++ b/tc/tc_util.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include #include @@ -105,6 +107,7 @@ int get_tc_classid(__u32 *h, const char *str) maj = TC_H_UNSPEC; if (strcmp(str, "none") == 0) goto ok; + errno = 0; maj = strtoul(str, &p, 16); if (p == str) { maj = 0; @@ -125,6 +128,10 @@ int get_tc_classid(__u32 *h, const char *str) } else if (*p != 0) return -1; + if (maj > UINT32_MAX || + (maj == ULONG_MAX && errno == ERANGE)) + return -1; + ok: *h = maj; return 0; base-commit: 06b62d179bbb5b62cba965dcda48a613dbc59416 -- 2.53.0