mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
cmd_parser: reject port 0 in the ingress command
The single-digit arm of the ingress parser guards with p - '1' > 9, which no digit can satisfy: the largest, '9', gives 8. The digit that needed rejecting is '0', which gives -1 and indexes one byte before phys_to_log_port, so "ingress 0 t" reads out of bounds and applies the ingress mode to whatever port number that byte happens to contain. Ports are 1-based, so reject anything below '1'; values above '9' are already excluded by the isnumber check before this.
This commit is contained in:
1 parent
59d20ed9b6
commit
a8d3b7d39a
1 file changed
+1
-1
+1
-1
@@ -529,7 +529,7 @@ void parse_ingress(void)
|
||||
if (!isnumber(p)) {
|
||||
continue;
|
||||
}
|
||||
if (p - '1' > 9) {
|
||||
if (p < '1') {
|
||||
print_string("Invalid physical port number: "); write_char(p); write_char('\n');
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user