]> Cypherpunks repositories - gostls13.git/commitdiff
http: prevent crash if remote server is not responding with "HTTP/"
authorRobert Griesemer <gri@golang.org>
Tue, 11 May 2010 23:50:20 +0000 (16:50 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 11 May 2010 23:50:20 +0000 (16:50 -0700)
Fixes #775.

R=rsc
CC=golang-dev
https://golang.org/cl/1180042

src/pkg/http/request.go

index 83a335bec07e496a95c0a13d39af116d1ad38459..27fbc3902abc7871913f53f1cdfd3c5a67d12120 100644 (file)
@@ -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)