chore: fix minor int coercion codeql vulnerability (#7024)

This commit is contained in:
Dean Sheather
2023-04-05 21:43:24 +00:00
committed by GitHub
parent c18ed6197c
commit 63f9ef2480
+2 -2
View File
@@ -336,8 +336,8 @@ func urlPort(u string) (int, error) {
return -1, xerrors.Errorf("invalid url %q: %w", u, err)
}
if parsed.Port() != "" {
port, err := strconv.ParseInt(parsed.Port(), 10, 64)
if err == nil && port > 0 {
port, err := strconv.ParseUint(parsed.Port(), 10, 16)
if err == nil && port > 0 && port < 1<<16 {
return int(port), nil
}
}