mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +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
-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