From: Robert Griesemer Date: Tue, 11 May 2010 23:50:20 +0000 (-0700) Subject: http: prevent crash if remote server is not responding with "HTTP/" X-Git-Tag: weekly.2010-05-27~90 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d6acc0646b68036cf53725e398e919b18e106acc;p=gostls13.git http: prevent crash if remote server is not responding with "HTTP/" Fixes #775. R=rsc CC=golang-dev https://golang.org/cl/1180042 --- 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)