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

Unified Diff: chrome/utility/importer/nss_decryptor.cc

Issue 427303004: Fix various bits of error-handling in NSSDecryptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: isherman comment Created 6 years, 4 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
« no previous file with comments | « chrome/utility/importer/firefox_importer_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/utility/importer/nss_decryptor.cc
diff --git a/chrome/utility/importer/nss_decryptor.cc b/chrome/utility/importer/nss_decryptor.cc
index 77a10a0bc044d1901b9f260cb9b980c81d9bc1fa..656b73ff8443a4e76c59c3ade82c62b67c7f879d 100644
--- a/chrome/utility/importer/nss_decryptor.cc
+++ b/chrome/utility/importer/nss_decryptor.cc
@@ -66,12 +66,16 @@ base::string16 NSSDecryptor::Decrypt(const std::string& crypt) const {
if (!is_nss_initialized_)
return base::string16();
+ if (crypt.empty())
+ return base::string16();
+
// The old style password is encoded in base64. They are identified
// by a leading '~'. Otherwise, we should decrypt the text.
std::string plain;
if (crypt[0] != '~') {
std::string decoded_data;
- base::Base64Decode(crypt, &decoded_data);
+ if (!base::Base64Decode(crypt, &decoded_data))
+ return base::string16();
PK11SlotInfo* slot = GetKeySlotForDB();
SECStatus result = PK11_Authenticate(slot, PR_TRUE, NULL);
if (result != SECSuccess) {
@@ -98,7 +102,8 @@ base::string16 NSSDecryptor::Decrypt(const std::string& crypt) const {
FreeSlot(slot);
} else {
// Deletes the leading '~' before decoding.
- base::Base64Decode(crypt.substr(1), &plain);
+ if (!base::Base64Decode(crypt.substr(1), &plain))
+ return base::string16();
}
return base::UTF8ToUTF16(plain);
« no previous file with comments | « chrome/utility/importer/firefox_importer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698