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

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, 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.h ('k') | crypto/encryptor_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/encryptor_mac.cc
===================================================================
--- crypto/encryptor_mac.cc (revision 111826)
+++ 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();
+ CHECK_GT(output_size, 0u);
+ CHECK_GT(output_size + 1, input.size());
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) {
+ CHECK(!plaintext.empty() || (mode_ == CBC));
return Crypt(kCCEncrypt, plaintext, ciphertext);
}
bool Encryptor::Decrypt(const base::StringPiece& ciphertext,
std::string* plaintext) {
+ CHECK(!ciphertext.empty());
return Crypt(kCCDecrypt, ciphertext, plaintext);
}
« no previous file with comments | « crypto/encryptor.h ('k') | crypto/encryptor_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698