From: Marcus Weiner Date: Wed, 24 Jun 2020 15:24:56 +0000 (+0000) Subject: [release-branch.go1.14] net/http: fix panic with If-None-Match value in http.ServeContent X-Git-Tag: go1.14.6~6 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=de0e24171921e4437c73c2e789a8d4d48396aac0;p=gostls13.git [release-branch.go1.14] net/http: fix panic with If-None-Match value in http.ServeContent Updates #39817. Fixes #39920. Change-Id: I79f2ad7c836a8a46569f603aca583fdd526d22dc GitHub-Last-Rev: 5b88aada219aaa2af0c7e1969ed6fa646117d9da GitHub-Pull-Request: golang/go#39821 Reviewed-on: https://go-review.googlesource.com/c/go/+/239699 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick (cherry picked from commit ce81a8f5e4f6c33036aa0777fabc47eeeab468dc) Reviewed-on: https://go-review.googlesource.com/c/go/+/240343 Run-TryBot: Emmanuel Odeke Reviewed-by: Emmanuel Odeke --- diff --git a/src/net/http/fs.go b/src/net/http/fs.go index d2144857e8..b8a68cc460 100644 --- a/src/net/http/fs.go +++ b/src/net/http/fs.go @@ -411,6 +411,7 @@ func checkIfNoneMatch(w ResponseWriter, r *Request) condResult { } if buf[0] == ',' { buf = buf[1:] + continue } if buf[0] == '*' { return condFalse diff --git a/src/net/http/fs_test.go b/src/net/http/fs_test.go index 435e34be3a..c082ceee71 100644 --- a/src/net/http/fs_test.go +++ b/src/net/http/fs_test.go @@ -849,6 +849,15 @@ func TestServeContent(t *testing.T) { wantStatus: 200, wantContentType: "text/css; charset=utf-8", }, + "if_none_match_malformed": { + file: "testdata/style.css", + serveETag: `"foo"`, + reqHeader: map[string]string{ + "If-None-Match": `,`, + }, + wantStatus: 200, + wantContentType: "text/css; charset=utf-8", + }, "range_good": { file: "testdata/style.css", serveETag: `"A"`,