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; |
} |