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

Unified Diff: net/tools/quic/quic_spdy_server_stream.cc

Issue 1308323012: Fix code relying on undocumented SimpleAtoi quirk, which caused rollback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clang_tidy_101595102
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_spdy_server_stream.cc
diff --git a/net/tools/quic/quic_spdy_server_stream.cc b/net/tools/quic/quic_spdy_server_stream.cc
index c47fc0c12890cdbebcff029ff0a61e81563e9e95..aeb56861c10c850bb54715af6078a222f434c6ef 100644
--- a/net/tools/quic/quic_spdy_server_stream.cc
+++ b/net/tools/quic/quic_spdy_server_stream.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_piece.h"
#include "net/quic/quic_data_stream.h"
#include "net/quic/quic_spdy_session.h"
#include "net/quic/spdy_utils.h"
@@ -97,9 +98,17 @@ bool QuicSpdyServerStream::ParseRequestHeaders(const char* data,
if (data_len > len) {
body_.append(data + len, data_len - len);
}
- if (ContainsKey(request_headers_, "content-length") &&
- !StringToInt(request_headers_["content-length"], &content_length_)) {
- return false; // Invalid content-length.
+ if (ContainsKey(request_headers_, "content-length")) {
+ // Historically, if an input to SimpleAtoi contained null byte, anything
+ // past it would be silently ignored. This behavior is being removed, but
+ // this method relies on it (see cl/101239633). Hence, we explicitly call
+ // c_str() on request headers to simulate the old behavior.
+ // TODO(rch): Correctly handle null-separated value in content-length.
+ // b/23554022
+ StringPiece trimmed_header(request_headers_["content-length"].c_str());
+ if (!StringToInt(trimmed_header, &content_length_)) {
+ return false; // Invalid content-length.
+ }
}
return true;
}
« 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