From d6acc0646b68036cf53725e398e919b18e106acc Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 11 May 2010 16:50:20 -0700 Subject: [PATCH] http: prevent crash if remote server is not responding with "HTTP/" Fixes #775. R=rsc CC=golang-dev https://golang.org/cl/1180042 --- src/pkg/http/request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/http/request.go b/src/pkg/http/request.go index 83a335bec0..27fbc3902a 100644 --- a/src/pkg/http/request.go +++ b/src/pkg/http/request.go @@ -345,7 +345,7 @@ func atoi(s string, i int) (n, i1 int, ok bool) { // Parse HTTP version: "HTTP/1.2" -> (1, 2, true). func parseHTTPVersion(vers string) (int, int, bool) { - if vers[0:5] != "HTTP/" { + if len(vers) < 5 || vers[0:5] != "HTTP/" { return 0, 0, false } major, i, ok := atoi(vers, 5)