From 440566c5d27eef67b402830a01034e57704f37cf Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 8 Jul 2021 11:25:32 -0700 Subject: [PATCH] net/interfaces: trim getPACWindows whitespace before parsing URL Fixes #2357 Signed-off-by: Brad Fitzpatrick --- net/interfaces/interfaces_windows.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/interfaces/interfaces_windows.go b/net/interfaces/interfaces_windows.go index 91f679c97..68eae6848 100644 --- a/net/interfaces/interfaces_windows.go +++ b/net/interfaces/interfaces_windows.go @@ -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 ""