aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/proxy_test.go
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2017-03-14 08:21:51 +0900
committerBrad Fitzpatrick <bradfitz@golang.org>2017-03-21 01:16:37 +0000
commit4e35e5fcabb504a14b9533692c9ae1a8c38b1139 (patch)
treef8189dd9109b5ab355402a9957554c6a1bf13b2d /src/net/http/proxy_test.go
parentdf68afd07ce67727bcc2ad8e4afaa42dbcbf58e7 (diff)
downloadgo-4e35e5fcabb504a14b9533692c9ae1a8c38b1139.tar.xz
net/http: fix ProxyFromEnvironment panic on invalid $NO_PROXY value
Given an entry in $no_proxy like ":1" we would interpret it as an empty host name and a port number, then check the first character of the host name for dots. This would then cause an index out of range panic. This change simply skips these entries, as the following checks would anyway have returned false. Fixes #19536 Change-Id: Iafe9c7a77ad4a6278c8ccb00a1575b56e4bdcd79 Reviewed-on: https://go-review.googlesource.com/38067 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/http/proxy_test.go')
-rw-r--r--src/net/http/proxy_test.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/net/http/proxy_test.go b/src/net/http/proxy_test.go
index 8d3a78b962..f59a551f0a 100644
--- a/src/net/http/proxy_test.go
+++ b/src/net/http/proxy_test.go
@@ -79,3 +79,9 @@ func ResetProxyEnv() {
}
ResetCachedEnvironment()
}
+
+func TestInvalidNoProxy(t *testing.T) {
+ ResetProxyEnv()
+ os.Setenv("NO_PROXY", ":1")
+ useProxy("example.com:80") // should not panic
+}