Skip to content

Commit be595c4

Browse files
committed
ecnconfig check against invalid argument value (sonic-net#343)
Signed-off-by: Wenda <[email protected]>
1 parent 6d00d14 commit be595c4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

scripts/ecnconfig

+10
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ class EcnConfig(object):
106106
def set_wred_threshold(self, profile, threshold, value):
107107
if os.geteuid() != 0:
108108
sys.exit("Root privileges required for this operation")
109+
110+
v = int(value)
111+
if v < 0 :
112+
raise Exception("Invalid %s" % (threshold))
113+
109114
field = WRED_CONFIG_FIELDS[threshold]
110115
if self.verbose:
111116
print("Setting %s value to %s" % (field, value))
@@ -114,6 +119,11 @@ class EcnConfig(object):
114119
def set_wred_prob(self, profile, drop_color, value):
115120
if os.geteuid() != 0:
116121
sys.exit("Root privileges required for this operation")
122+
123+
v = int(value)
124+
if v < 0 or v > 100:
125+
raise Exception("Invalid %s" % (drop_color))
126+
117127
field = WRED_CONFIG_FIELDS[drop_color]
118128
if self.verbose:
119129
print("Setting %s value to %s%%" % (field, value))

0 commit comments

Comments
 (0)