diff mbox series

ubox validate: port range check fix

Message ID 20240920162345.11985-1-newtwen+github@gmail.com
State New
Headers show
Series ubox validate: port range check fix | expand

Commit Message

Paul Donald Sept. 20, 2024, 4:23 p.m. UTC
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 <newtwen+github@gmail.com>
---
 validate/validate.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Paul Donald Oct. 17, 2024, 1:37 p.m. UTC | #1
ping

On 2024-09-20 18:23, Paul Donald wrote:
> 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 <newtwen+github@gmail.com>
> ---
>  validate/validate.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/validate/validate.c b/validate/validate.c
> index e72b811..ffea1d5 100644
> --- a/validate/validate.c
> +++ b/validate/validate.c
> @@ -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);
>
diff mbox series

Patch

diff --git a/validate/validate.c b/validate/validate.c
index e72b811..ffea1d5 100644
--- a/validate/validate.c
+++ b/validate/validate.c
@@ -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);