Commit d6acc064 authored by Robert Griesemer's avatar Robert Griesemer

http: prevent crash if remote server is not responding with "HTTP/"

Fixes #775.

R=rsc
CC=golang-dev
https://golang.org/cl/1180042
parent 75dbbd21
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment