From bddc882f7d12a0d178a5735a07036224f2507bff Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 10 Nov 2020 11:30:05 -0800 Subject: [PATCH] net/interfaces: ignore bogus proxy URLs from winhttp [windows] Updates tailscale/corp#853 (cherry picked from commit d192bd0f860e6beacc63390b9b21a7b691923d31) --- net/interfaces/interfaces_windows.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/interfaces/interfaces_windows.go b/net/interfaces/interfaces_windows.go index bf6fff8a9..19e9b48b4 100644 --- a/net/interfaces/interfaces_windows.go +++ b/net/interfaces/interfaces_windows.go @@ -7,6 +7,7 @@ package interfaces import ( "fmt" "log" + "net/url" "os/exec" "syscall" "unsafe" @@ -176,7 +177,12 @@ func getPACWindows() string { return "" } defer globalFree.Call(uintptr(unsafe.Pointer(res))) - return windows.UTF16PtrToString(res) + s := windows.UTF16PtrToString(res) + if _, err := url.Parse(s); err != nil { + log.Printf("getPACWindows: invalid URL %q from winhttp; ignoring", s) + return "" + } + return s } const ( ERROR_WINHTTP_AUTODETECTION_FAILED = 12180