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:
bloqaudio
2026-08-17 17:19:46 -05:00
parent 59d20ed9b6
commit a8d3b7d39a
+1 -1
View File
@@ -529,7 +529,7 @@ void parse_ingress(void)
if (!isnumber(p)) { if (!isnumber(p)) {
continue; continue;
} }
if (p - '1' > 9) { if (p < '1') {
print_string("Invalid physical port number: "); write_char(p); write_char('\n'); print_string("Invalid physical port number: "); write_char(p); write_char('\n');
continue; continue;
} }