Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: net/http/http_vary_data.cc

Issue 2012463002: Fix a crash in HttpVaryData::MatchesRequests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_vary_data.h" 5 #include "net/http/http_vary_data.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void HttpVaryData::Persist(base::Pickle* pickle) const { 61 void HttpVaryData::Persist(base::Pickle* pickle) const {
62 DCHECK(is_valid()); 62 DCHECK(is_valid());
63 pickle->WriteBytes(&request_digest_, sizeof(request_digest_)); 63 pickle->WriteBytes(&request_digest_, sizeof(request_digest_));
64 } 64 }
65 65
66 bool HttpVaryData::MatchesRequest( 66 bool HttpVaryData::MatchesRequest(
67 const HttpRequestInfo& request_info, 67 const HttpRequestInfo& request_info,
68 const HttpResponseHeaders& cached_response_headers) const { 68 const HttpResponseHeaders& cached_response_headers) const {
69 HttpVaryData new_vary_data; 69 HttpVaryData new_vary_data;
70 if (!new_vary_data.Init(request_info, cached_response_headers)) { 70 if (!new_vary_data.Init(request_info, cached_response_headers)) {
71 // This shouldn't happen provided the same response headers passed here 71 // This case can happen if |this| was loaded from a cache that was populated
72 // were also used when initializing |this|. 72 // by a build before crbug.com/469675 was fixed.
73 NOTREACHED();
74 return false; 73 return false;
75 } 74 }
76 return memcmp(&new_vary_data.request_digest_, &request_digest_, 75 return memcmp(&new_vary_data.request_digest_, &request_digest_,
77 sizeof(request_digest_)) == 0; 76 sizeof(request_digest_)) == 0;
78 } 77 }
79 78
80 // static 79 // static
81 std::string HttpVaryData::GetRequestValue( 80 std::string HttpVaryData::GetRequestValue(
82 const HttpRequestInfo& request_info, 81 const HttpRequestInfo& request_info,
83 const std::string& request_header) { 82 const std::string& request_header) {
(...skipping 17 matching lines...) Expand all
101 // Append a character that cannot appear in the request header line so that we 100 // Append a character that cannot appear in the request header line so that we
102 // protect against case where the concatenation of two request headers could 101 // protect against case where the concatenation of two request headers could
103 // look the same for a variety of values for the individual request headers. 102 // look the same for a variety of values for the individual request headers.
104 // For example, "foo: 12\nbar: 3" looks like "foo: 1\nbar: 23" otherwise. 103 // For example, "foo: 12\nbar: 3" looks like "foo: 1\nbar: 23" otherwise.
105 request_value.append(1, '\n'); 104 request_value.append(1, '\n');
106 105
107 base::MD5Update(ctx, request_value); 106 base::MD5Update(ctx, request_value);
108 } 107 }
109 108
110 } // namespace net 109 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698