From be595c432a4708cb02f55704c3184b9283fd5651 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Sat, 13 Oct 2018 13:45:18 -0700 Subject: [PATCH] ecnconfig check against invalid argument value (#343) Signed-off-by: Wenda --- scripts/ecnconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/ecnconfig b/scripts/ecnconfig index eceb66831d00..f5ca6635bc2a 100755 --- a/scripts/ecnconfig +++ b/scripts/ecnconfig @@ -106,6 +106,11 @@ class EcnConfig(object): def set_wred_threshold(self, profile, threshold, value): if os.geteuid() != 0: sys.exit("Root privileges required for this operation") + + v = int(value) + if v < 0 : + raise Exception("Invalid %s" % (threshold)) + field = WRED_CONFIG_FIELDS[threshold] if self.verbose: print("Setting %s value to %s" % (field, value)) @@ -114,6 +119,11 @@ class EcnConfig(object): def set_wred_prob(self, profile, drop_color, value): if os.geteuid() != 0: sys.exit("Root privileges required for this operation") + + v = int(value) + if v < 0 or v > 100: + raise Exception("Invalid %s" % (drop_color)) + field = WRED_CONFIG_FIELDS[drop_color] if self.verbose: print("Setting %s value to %s%%" % (field, value))