Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: crypto/encryptor_openssl.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/encryptor_nss.cc ('k') | crypto/encryptor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/encryptor_openssl.cc
===================================================================
--- crypto/encryptor_openssl.cc (revision 111826)
+++ 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;
« no previous file with comments | « crypto/encryptor_nss.cc ('k') | crypto/encryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698