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

Unified Diff: crypto/encryptor_win.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_unittest.cc ('k') | crypto/symmetric_key.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/encryptor_win.cc
===================================================================
--- crypto/encryptor_win.cc (revision 111826)
+++ crypto/encryptor_win.cc (working copy)
@@ -83,8 +83,10 @@
bool Encryptor::Encrypt(const base::StringPiece& plaintext,
std::string* ciphertext) {
DWORD data_len = plaintext.size();
+ CHECK((data_len > 0u) || (mode_ == CBC));
DWORD total_len = data_len + block_size_;
- CHECK_GT(total_len, data_len);
+ CHECK_GT(total_len, 0u);
+ CHECK_GT(total_len + 1, data_len);
// CryptoAPI encrypts/decrypts in place.
char* ciphertext_data = WriteInto(ciphertext, total_len + 1);
@@ -105,8 +107,8 @@
bool Encryptor::Decrypt(const base::StringPiece& ciphertext,
std::string* plaintext) {
DWORD data_len = ciphertext.size();
- if (data_len == 0 || (data_len + 1) < data_len)
- return false;
+ CHECK_GT(data_len, 0u);
+ CHECK_GT(data_len + 1, data_len);
// CryptoAPI encrypts/decrypts in place.
char* plaintext_data = WriteInto(plaintext, data_len + 1);
« no previous file with comments | « crypto/encryptor_unittest.cc ('k') | crypto/symmetric_key.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698