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

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, 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_win.cc
===================================================================
--- crypto/encryptor_win.cc (revision 107404)
+++ 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();
+ DCHECK((data_len > 0u) || (mode_ == CBC));
DWORD total_len = data_len + block_size_;
- CHECK_GT(total_len, data_len);
+ DCHECK_GT(total_len, 0u);
+ DCHECK_GT(total_len + 1, data_len);
Ryan Sleevi 2011/11/01 23:08:59 86, 88, 89 -> CHECK variants
// 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;
+ DCHECK_GT(data_len, 0u);
+ DCHECK_GT(data_len + 1, data_len);
Ryan Sleevi 2011/11/01 23:08:59 both of these to CHECK_GT
// CryptoAPI encrypts/decrypts in place.
char* plaintext_data = WriteInto(plaintext, data_len + 1);

Powered by Google App Engine
This is Rietveld 408576698