From 6565262571773d6a9ff01761e2358ada0f00be0b Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Fri, 29 Aug 2014 12:20:21 +0200 Subject: [PATCH] netdev-linux: Cast policer rate to uint64_t to avoid overflow tc_fill_rate() takes a 64bit int, casting kbits_rate from int to uint64_t avoids a possible overflow when translating from kbits to bytes. Signed-off-by: Thomas Graf Signed-off-by: Ben Pfaff --- lib/netdev-linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 840022d77..e05ba6057 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -4026,7 +4026,7 @@ tc_add_policer(struct netdev *netdev, int kbits_rate, int kbits_burst) memset(&tc_police, 0, sizeof tc_police); tc_police.action = TC_POLICE_SHOT; tc_police.mtu = mtu; - tc_fill_rate(&tc_police.rate, (kbits_rate * 1000)/8, mtu); + tc_fill_rate(&tc_police.rate, ((uint64_t) kbits_rate * 1000)/8, mtu); tc_police.burst = tc_bytes_to_ticks(tc_police.rate.rate, kbits_burst * 1024); -- 2.20.1