net/interfaces: trim getPACWindows whitespace before parsing URL

Fixes #2357

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/2364/head
Brad Fitzpatrick 3 years ago
parent 1e83b97498
commit 440566c5d2

@ -9,6 +9,7 @@ import (
"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 ""

Loading…
Cancel
Save