net/interfaces: trim getPACWindows whitespace before parsing URL

Fixes #2357

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2021-07-08 11:25:32 -07:00
parent 1e83b97498
commit 440566c5d2

View File

@ -9,6 +9,7 @@
"log"
"net"
"net/url"
"strings"
"syscall"
"unsafe"
@ -198,6 +199,10 @@ func getPACWindows() string {
}
defer globalFree.Call(uintptr(unsafe.Pointer(res)))
s := windows.UTF16PtrToString(res)
s = strings.TrimSpace(s)
if s == "" {
return "" // Issue 2357: invalid URL "\n" from winhttp; ignoring
}
if _, err := url.Parse(s); err != nil {
log.Printf("getPACWindows: invalid URL %q from winhttp; ignoring", s)
return ""