Chromium Code Reviews| Index: crypto/encryptor_openssl.cc |
| =================================================================== |
| --- crypto/encryptor_openssl.cc (revision 107404) |
| +++ crypto/encryptor_openssl.cc (working copy) |
| @@ -73,11 +73,13 @@ |
| bool Encryptor::Encrypt(const base::StringPiece& plaintext, |
| std::string* ciphertext) { |
| + DCHECK(!plaintext.empty() || (mode_ == CBC)); |
| return Crypt(true, plaintext, ciphertext); |
| } |
| bool Encryptor::Decrypt(const base::StringPiece& ciphertext, |
| std::string* plaintext) { |
| + DCHECK(!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); |
| + DCHECK_GT(output_size, 0u); |
| + DCHECK_GT(output_size + 1, input.size()); |
|
Ryan Sleevi
2011/11/01 23:08:59
Promote both of these to CHECK_GT
|
| uint8* out_ptr = reinterpret_cast<uint8*>(WriteInto(&result, |
| output_size + 1)); |
| int out_len; |