From 763bcf3b67f01239f2bdf24ec583d0376b20741e Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Sun, 1 Dec 2024 18:28:48 -0600 Subject: [PATCH 1/2] Use ParseUint to test for overflow directly --- config/load.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config/load.go b/config/load.go index 9754e9a66..1827ff22f 100644 --- a/config/load.go +++ b/config/load.go @@ -570,13 +570,10 @@ func parseTLSCiphers(s string) ([]uint16, error) { } func parseUint16(s string) (uint16, error) { - n, err := strconv.ParseUint(s, 0, 32) + n, err := strconv.ParseUint(s, 10, 16) if err != nil { return 0, err } - if n > 1<<16 { - return 0, fmt.Errorf("%d out of range: [0..65535]", n) - } return uint16(n), nil } From b75edc767dd441487c163e10ed601922a976d591 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Sun, 1 Dec 2024 18:32:47 -0600 Subject: [PATCH 2/2] Use 0 for base --- config/load.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/load.go b/config/load.go index 1827ff22f..b3fe1a654 100644 --- a/config/load.go +++ b/config/load.go @@ -570,7 +570,7 @@ func parseTLSCiphers(s string) ([]uint16, error) { } func parseUint16(s string) (uint16, error) { - n, err := strconv.ParseUint(s, 10, 16) + n, err := strconv.ParseUint(s, 0, 16) if err != nil { return 0, err }