mirror of
https://github.com/golang/go
synced 2024-11-20 04:04:41 -07:00
http: prevent crash if remote server is not responding with "HTTP/"
Fixes #775. R=rsc CC=golang-dev https://golang.org/cl/1180042
This commit is contained in:
parent
75dbbd2137
commit
d6acc0646b
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user