From 8244910842efd818962b217447989f7e72b63401 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Wed, 8 Feb 2023 11:41:05 -0500 Subject: [PATCH] parsing tweaks (#211) --- cmd/zrok/util.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/zrok/util.go b/cmd/zrok/util.go index bff5c9fb..6a04d288 100644 --- a/cmd/zrok/util.go +++ b/cmd/zrok/util.go @@ -5,6 +5,7 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/pkg/errors" + "math" "net/url" "os" "strconv" @@ -22,13 +23,13 @@ func mustGetAdminAuth() runtime.ClientAuthInfoWriter { func parseUrl(in string) (string, error) { // parse port-only urls if iv, err := strconv.ParseInt(in, 10, 0); err == nil { - if iv > 0 && iv < 65536 { + if iv > 0 && iv <= math.MaxUint16 { if iv == 443 { return fmt.Sprintf("https://127.0.0.1:%d", iv), nil } return fmt.Sprintf("http://127.0.0.1:%d", iv), nil } - return "", errors.Errorf("ports must be between 1 and 65536; %d is not", iv) + return "", errors.Errorf("ports must be between 1 and %d; %d is not", math.MaxUint16, iv) } // make sure either https:// or http:// was specified