Skip to content

Commit

Permalink
Merge pull request #961 from fabiolb/dcarbone/parse-uint16
Browse files Browse the repository at this point in the history
Use ParseUint to test for overflow directly
  • Loading branch information
dcarbone authored Dec 2, 2024
2 parents c520d1a + b75edc7 commit c2e0c36
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, 0, 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
}

Expand Down

0 comments on commit c2e0c36

Please sign in to comment.