Index: components/gcm_driver/crypto/gcm_message_cryptographer.cc |
diff --git a/components/gcm_driver/crypto/gcm_message_cryptographer.cc b/components/gcm_driver/crypto/gcm_message_cryptographer.cc |
index deaaba33a50f9981729e08e219c3aec98434e3b9..8fe8166bf51c350f8a312014b6e47341a399df6e 100644 |
--- a/components/gcm_driver/crypto/gcm_message_cryptographer.cc |
+++ b/components/gcm_driver/crypto/gcm_message_cryptographer.cc |
@@ -57,10 +57,8 @@ class WebPushEncryptionDraft03 |
const base::StringPiece& auth_secret) override { |
const char kInfo[] = "Content-Encoding: auth"; |
- std::string info; |
- info.reserve(sizeof(kInfo) + 1); |
- info.append(kInfo); |
- info.append(1, '\0'); |
+ // This deliberately copies over the NUL terminus. |
+ std::string info(kInfo, sizeof(kInfo)); |
eroman
2017/05/23 18:20:08
How about using a StringPiece instead? (avoids cop
Peter Beverloo
2017/05/23 19:01:21
Done.
|
crypto::HKDF hkdf(ecdh_shared_secret, auth_secret, info, |
32, /* key_bytes_to_generate */ |
@@ -197,9 +195,10 @@ class WebPushEncryptionDraft08 |
const char kInfo[] = "WebPush: info"; |
std::string info; |
- info.reserve(sizeof(kInfo) + 1 + 65 + 65); |
- info.append(kInfo); |
- info.append(1, '\0'); |
+ info.reserve(sizeof(kInfo) + 65 + 65); |
+ |
+ // This deliberately copies over the NUL terminus. |
+ info.append(kInfo, sizeof(kInfo)); |
recipient_public_key.AppendToString(&info); |
sender_public_key.AppendToString(&info); |