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

Unified Diff: net/http/http_mac_signature.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « net/disk_cache/entry_impl.cc ('k') | net/http/http_mac_signature_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_mac_signature.cc
===================================================================
--- net/http/http_mac_signature.cc (revision 111826)
+++ net/http/http_mac_signature.cc (working copy)
@@ -158,9 +158,12 @@
std::string signature;
size_t length = hmac.DigestLength();
- char* buffer = WriteInto(&signature, length);
- if (!hmac.Sign(request, reinterpret_cast<unsigned char*>(buffer),
- length)) {
+ DCHECK_GT(length, 0u);
+ if (!hmac.Sign(request,
+ // We need the + 1 here not because the call will write a trailing \0,
+ // but so that signature.length() is correctly set to |length|.
+ reinterpret_cast<unsigned char*>(WriteInto(&signature, length + 1)),
+ length)) {
NOTREACHED();
return false;
}
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/http/http_mac_signature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698