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

Unified Diff: net/http/http_util.cc

Issue 7796025: Don't interpret embeded NULLs in a response header line as a line terminator. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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
Index: net/http/http_util.cc
===================================================================
--- net/http/http_util.cc (revision 100022)
+++ net/http/http_util.cc (working copy)
@@ -547,7 +547,7 @@
raw_headers.append(FindFirstNonLWS(line_begin, line_end), line_end);
} else {
// Terminate the previous line.
- raw_headers.push_back('\0');
+ raw_headers.push_back('\n');
// Copy the raw data to output.
raw_headers.append(line_begin, line_end);
@@ -557,7 +557,15 @@
}
}
- raw_headers.append("\0\0", 2);
+ raw_headers.append("\n\n", 2);
+
+ // Use '\0' as the canonical line terminator. If the input already contained
+ // any embeded NULLs we will strip them first to avoid interpreting them as
wtc 2011/09/12 18:48:09 Nit: NULLs => '\0' characters for consistenty.
eroman 2011/09/12 21:19:24 Done.
+ // line breaks.
+ raw_headers.erase(std::remove(raw_headers.begin(), raw_headers.end(), '\0'),
+ raw_headers.end());
+ std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0');
wtc 2011/09/12 18:48:09 This seems a high cost (two extra linear scans of
eroman 2011/09/12 21:19:24 I did some performance tests for moderate sized he
+
return raw_headers;
}

Powered by Google App Engine
This is Rietveld 408576698