Index: crypto/hkdf.cc |
diff --git a/crypto/hkdf.cc b/crypto/hkdf.cc |
index e621bcb45b0818d64bce70893ba8308f39bca168..27388f9764639ed999acb728b376fd0d9702c23f 100644 |
--- a/crypto/hkdf.cc |
+++ b/crypto/hkdf.cc |
@@ -72,17 +72,24 @@ HKDF::HKDF(const base::StringPiece& secret, |
} |
size_t j = 0; |
- client_write_key_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]), |
- key_bytes_to_generate); |
- j += key_bytes_to_generate; |
- server_write_key_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]), |
- key_bytes_to_generate); |
- j += key_bytes_to_generate; |
- client_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]), |
- iv_bytes_to_generate); |
- j += iv_bytes_to_generate; |
- server_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]), |
- iv_bytes_to_generate); |
+ // On Windows, when output's size is zero, dereference of 0'th element results |
wtc
2013/03/14 00:38:08
output's => the size of output_
because "output_'
ramant (doing other things)
2013/03/14 03:05:15
Deleted this comment
ramant (doing other things)
2013/03/14 03:26:20
Added the comment.
|
+ // in a crash. C++11 solves this problem by passing std::vector's data. |
wtc
2013/03/14 00:38:08
This should read:
C++11 solves this problem by a
ramant (doing other things)
2013/03/14 03:05:15
Changed the code to use output_.data() + j. Thanks
ramant (doing other things)
2013/03/14 03:26:20
Added the comment. output_.data() + j is not suppo
|
+ if (key_bytes_to_generate > 0) { |
+ client_write_key_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]), |
+ key_bytes_to_generate); |
+ j += key_bytes_to_generate; |
+ server_write_key_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]), |
+ key_bytes_to_generate); |
+ j += key_bytes_to_generate; |
+ } |
+ |
+ if (iv_bytes_to_generate > 0) { |
+ client_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]), |
+ iv_bytes_to_generate); |
+ j += iv_bytes_to_generate; |
+ server_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]), |
+ iv_bytes_to_generate); |
+ } |
} |
HKDF::~HKDF() { |