Chromium Code Reviews| Index: net/http/http_response_headers.cc |
| diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc |
| index 691536b3bbd11e104d5129db7d91985e497c8be2..f84fe6bff7a50e73291150b141f2b7277e8faba3 100644 |
| --- a/net/http/http_response_headers.cc |
| +++ b/net/http/http_response_headers.cc |
| @@ -390,9 +390,13 @@ void HttpResponseHeaders::Parse(const std::string& raw_input) { |
| (line_end + 1) != raw_input.end() && |
| *(line_end + 1) != '\0'); |
| ParseStatusLine(line_begin, line_end, has_headers); |
| + raw_headers_.push_back('\0'); // terminate status line with a null |
|
rvargas (doing something else)
2011/11/30 22:53:09
Nit: Start with uppercase and end with period.
|
| if (line_end == raw_input.end()) { |
| - raw_headers_.push_back('\0'); |
| + raw_headers_.push_back('\0'); // ensure the headers end with a double null |
|
rvargas (doing something else)
2011/11/30 22:53:09
ibid
|
| + |
| + DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 2]); |
| + DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 1]); |
| return; |
| } |
| @@ -414,6 +418,16 @@ void HttpResponseHeaders::Parse(const std::string& raw_input) { |
| headers.values_begin(), |
| headers.values_end()); |
| } |
| + |
| + // Ensure the headers end with a double null. |
| + while (raw_headers_.size() < 2 || |
| + raw_headers_[raw_headers_.size() - 2] != '\0' || |
| + raw_headers_[raw_headers_.size() - 1] != '\0') { |
| + raw_headers_.push_back('\0'); |
| + } |
| + |
| + DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 2]); |
| + DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 1]); |
| } |
| // Append all of our headers to the final output string. |
| @@ -663,7 +677,6 @@ void HttpResponseHeaders::ParseStatusLine( |
| if (p == line_end) { |
| DVLOG(1) << "missing response status; assuming 200 OK"; |
| raw_headers_.append(" 200 OK"); |
| - raw_headers_.push_back('\0'); |
| response_code_ = 200; |
| return; |
| } |
| @@ -703,8 +716,6 @@ void HttpResponseHeaders::ParseStatusLine( |
| } else { |
| raw_headers_.append(p, line_end); |
| } |
| - |
| - raw_headers_.push_back('\0'); |
| } |
| size_t HttpResponseHeaders::FindHeader(size_t from, |