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

Unified Diff: crypto/encryptor_mac.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, 2 months 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
Index: crypto/encryptor_mac.cc
===================================================================
--- crypto/encryptor_mac.cc (revision 107404)
+++ crypto/encryptor_mac.cc (working copy)
@@ -49,17 +49,19 @@
// length is never larger than the input length plus the block size."
size_t output_size = input.size() + iv_.size();
+ DCHECK_GT(output_size, 0u);
+ DCHECK_GT(output_size + 1, input.size());
Ryan Sleevi 2011/11/01 23:08:59 Both of these can be changed to CHECK_GT
CCCryptorStatus err = CCCrypt(op,
kCCAlgorithmAES128,
kCCOptionPKCS7Padding,
raw_key.Data, raw_key.Length,
iv_.data(),
input.data(), input.size(),
- WriteInto(output, output_size+1),
+ WriteInto(output, output_size + 1),
output_size,
&output_size);
if (err) {
- output->resize(0);
+ output->clear();
LOG(ERROR) << "CCCrypt returned " << err;
return false;
}
@@ -69,11 +71,13 @@
bool Encryptor::Encrypt(const base::StringPiece& plaintext,
std::string* ciphertext) {
+ DCHECK(!plaintext.empty() || (mode_ == CBC));
return Crypt(kCCEncrypt, plaintext, ciphertext);
}
bool Encryptor::Decrypt(const base::StringPiece& ciphertext,
std::string* plaintext) {
+ DCHECK(!ciphertext.empty());
return Crypt(kCCDecrypt, ciphertext, plaintext);
}
« no previous file with comments | « crypto/encryptor.h ('k') | crypto/encryptor_nss.cc » ('j') | crypto/encryptor_nss.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698