| Index: crypto/encryptor_openssl.cc
|
| ===================================================================
|
| --- crypto/encryptor_openssl.cc (revision 108344)
|
| +++ crypto/encryptor_openssl.cc (working copy)
|
| @@ -73,11 +73,13 @@
|
|
|
| bool Encryptor::Encrypt(const base::StringPiece& plaintext,
|
| std::string* ciphertext) {
|
| + CHECK(!plaintext.empty() || (mode_ == CBC));
|
| return Crypt(true, plaintext, ciphertext);
|
| }
|
|
|
| bool Encryptor::Decrypt(const base::StringPiece& ciphertext,
|
| std::string* plaintext) {
|
| + CHECK(!ciphertext.empty());
|
| return Crypt(false, ciphertext, plaintext);
|
| }
|
|
|
| @@ -88,7 +90,7 @@
|
| // Work on the result in a local variable, and then only transfer it to
|
| // |output| on success to ensure no partial data is returned.
|
| std::string result;
|
| - output->swap(result);
|
| + output->clear();
|
|
|
| const EVP_CIPHER* cipher = GetCipherForKey(key_);
|
| DCHECK(cipher); // Already handled in Init();
|
| @@ -106,6 +108,8 @@
|
|
|
| // When encrypting, add another block size of space to allow for any padding.
|
| const size_t output_size = input.size() + (do_encrypt ? iv_.size() : 0);
|
| + CHECK_GT(output_size, 0u);
|
| + CHECK_GT(output_size + 1, input.size());
|
| uint8* out_ptr = reinterpret_cast<uint8*>(WriteInto(&result,
|
| output_size + 1));
|
| int out_len;
|
|
|