ubox validate: port range check fix master
authorPaul Donald <[email protected]>
Fri, 20 Sep 2024 15:55:13 +0000 (17:55 +0200)
committerRobert Marko <[email protected]>
Thu, 30 Oct 2025 11:10:12 +0000 (12:10 +0100)
The luci GUI allows a single port in a port range field. This additional
check validates a single port if a range was not found.

Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/ubox/pull/7
Signed-off-by: Robert Marko <[email protected]>
validate/validate.c

index e72b8117ecd8b680778b0f5c7637ed6546a7736b..ffea1d521316829a0e774fbf106c29a6091488e2 100644 (file)
@@ -597,8 +597,10 @@ dt_type_portrange(struct dt_state *s, int nargs)
 
        n = strtoul(s->value, &e, 10);
 
-       if (e == s->value || *e != '-')
-               return false;
+       if (e == s->value || *e != '-') {
+               // If parsing as portrange fails, try parsing as a single port
+               return dt_type_port(s, nargs);
+       }
 
        m = strtoul(e + 1, &e, 10);