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

Side by Side Diff: chrome/utility/importer/nss_decryptor_win.cc

Issue 23799008: Fix import Firefox passwords on Windows (silent failure); plds4.dll and nspr4.dll no longer exist (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/utility/importer/nss_decryptor_win.h" 5 #include "chrome/utility/importer/nss_decryptor_win.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 9
10 namespace { 10 namespace {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // harmless for NSS 3.11. 78 // harmless for NSS 3.11.
79 path = base::FilePath(dll_path).Append(kSoftokn3Library); 79 path = base::FilePath(dll_path).Append(kSoftokn3Library);
80 softokn3_dll_ = LoadLibraryEx(path.value().c_str(), NULL, 80 softokn3_dll_ = LoadLibraryEx(path.value().c_str(), NULL,
81 LOAD_WITH_ALTERED_SEARCH_PATH); 81 LOAD_WITH_ALTERED_SEARCH_PATH);
82 if (softokn3_dll_ == NULL) { 82 if (softokn3_dll_ == NULL) {
83 Free(); 83 Free();
84 return false; 84 return false;
85 } 85 }
86 } 86 }
87 HMODULE plds4_dll = GetModuleHandle(kPLDS4Library); 87 HMODULE plds4_dll = GetModuleHandle(kPLDS4Library);
88 HMODULE nspr4_dll = GetModuleHandle(kNSPR4Library); 88 HMODULE nspr4_dll = GetModuleHandle(kNSPR4Library);
wtc 2013/09/11 23:44:03 We can also handle the problem here: // On Fire
89 89
90 return InitNSS(db_path, plds4_dll, nspr4_dll); 90 return InitNSS(db_path, plds4_dll, nspr4_dll);
91 } 91 }
92 92
93 NSSDecryptor::NSSDecryptor() 93 NSSDecryptor::NSSDecryptor()
94 : NSS_Init(NULL), NSS_Shutdown(NULL), PK11_GetInternalKeySlot(NULL), 94 : NSS_Init(NULL), NSS_Shutdown(NULL), PK11_GetInternalKeySlot(NULL),
95 PK11_CheckUserPassword(NULL), PK11_FreeSlot(NULL), 95 PK11_CheckUserPassword(NULL), PK11_FreeSlot(NULL),
96 PK11_Authenticate(NULL), PK11SDR_Decrypt(NULL), SECITEM_FreeItem(NULL), 96 PK11_Authenticate(NULL), PK11SDR_Decrypt(NULL), SECITEM_FreeItem(NULL),
97 PL_ArenaFinish(NULL), PR_Cleanup(NULL), 97 PL_ArenaFinish(NULL), PR_Cleanup(NULL),
98 nss3_dll_(NULL), softokn3_dll_(NULL), 98 nss3_dll_(NULL), softokn3_dll_(NULL),
99 is_nss_initialized_(false) { 99 is_nss_initialized_(false) {
100 } 100 }
101 101
102 NSSDecryptor::~NSSDecryptor() { 102 NSSDecryptor::~NSSDecryptor() {
103 Free(); 103 Free();
104 } 104 }
105 105
106 bool NSSDecryptor::InitNSS(const base::FilePath& db_path, 106 bool NSSDecryptor::InitNSS(const base::FilePath& db_path,
107 base::NativeLibrary plds4_dll, 107 base::NativeLibrary plds4_dll,
108 base::NativeLibrary nspr4_dll) { 108 base::NativeLibrary nspr4_dll) {
109 // NSPR DLLs are already loaded now.
110 if (plds4_dll == NULL || nspr4_dll == NULL) {
111 Free();
112 return false;
113 }
114
115 // Gets the function address. 109 // Gets the function address.
116 NSS_Init = (NSSInitFunc) 110 NSS_Init = (NSSInitFunc)
117 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Init"); 111 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Init");
118 NSS_Shutdown = (NSSShutdownFunc) 112 NSS_Shutdown = (NSSShutdownFunc)
119 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Shutdown"); 113 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Shutdown");
120 PK11_GetInternalKeySlot = (PK11GetInternalKeySlotFunc) 114 PK11_GetInternalKeySlot = (PK11GetInternalKeySlotFunc)
121 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, 115 base::GetFunctionPointerFromNativeLibrary(nss3_dll_,
122 "PK11_GetInternalKeySlot"); 116 "PK11_GetInternalKeySlot");
123 PK11_FreeSlot = (PK11FreeSlotFunc) 117 PK11_FreeSlot = (PK11FreeSlotFunc)
124 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_FreeSlot"); 118 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_FreeSlot");
125 PK11_Authenticate = (PK11AuthenticateFunc) 119 PK11_Authenticate = (PK11AuthenticateFunc)
126 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_Authenticate"); 120 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_Authenticate");
127 PK11SDR_Decrypt = (PK11SDRDecryptFunc) 121 PK11SDR_Decrypt = (PK11SDRDecryptFunc)
128 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11SDR_Decrypt"); 122 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11SDR_Decrypt");
129 SECITEM_FreeItem = (SECITEMFreeItemFunc) 123 SECITEM_FreeItem = (SECITEMFreeItemFunc)
130 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "SECITEM_FreeItem"); 124 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "SECITEM_FreeItem");
131 PL_ArenaFinish = (PLArenaFinishFunc) 125 // On Firefox 22 and higher, PL_ArenaFinish() and PR_Cleanup() are found in
132 base::GetFunctionPointerFromNativeLibrary(plds4_dll, "PL_ArenaFinish"); 126 // nss3.dll rather than plds4.dll.
wtc 2013/09/11 23:44:03 plds4.dll => plds4.dll and nspr4.dll. This is a r
133 PR_Cleanup = (PRCleanupFunc) 127 if (plds4_dll == NULL) {
134 base::GetFunctionPointerFromNativeLibrary(nspr4_dll, "PR_Cleanup"); 128 PL_ArenaFinish = (PLArenaFinishFunc)(
129 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PL_ArenaFinish"));
130 PR_Cleanup = (PRCleanupFunc)(
131 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PR_Cleanup"));
132 } else {
133 PL_ArenaFinish = (PLArenaFinishFunc)(
134 base::GetFunctionPointerFromNativeLibrary(nspr4_dll, "PL_ArenaFinish"));
Ilya Sherman 2013/09/11 23:39:40 Unless I'm misreading something, this was plds4_dl
wtc 2013/09/11 23:44:03 We need to use plds4_dll here.
135 PR_Cleanup = (PRCleanupFunc)(
136 base::GetFunctionPointerFromNativeLibrary(nspr4_dll, "PR_Cleanup"));
137 }
135 138
136 if (NSS_Init == NULL || NSS_Shutdown == NULL || 139 if (NSS_Init == NULL || NSS_Shutdown == NULL ||
137 PK11_GetInternalKeySlot == NULL || PK11_FreeSlot == NULL || 140 PK11_GetInternalKeySlot == NULL || PK11_FreeSlot == NULL ||
138 PK11_Authenticate == NULL || PK11SDR_Decrypt == NULL || 141 PK11_Authenticate == NULL || PK11SDR_Decrypt == NULL ||
139 SECITEM_FreeItem == NULL || PL_ArenaFinish == NULL || 142 SECITEM_FreeItem == NULL || PL_ArenaFinish == NULL ||
140 PR_Cleanup == NULL) { 143 PR_Cleanup == NULL) {
141 Free(); 144 Free();
142 return false; 145 return false;
143 } 146 }
144 147
(...skipping 23 matching lines...) Expand all
168 PK11_GetInternalKeySlot = NULL; 171 PK11_GetInternalKeySlot = NULL;
169 PK11_FreeSlot = NULL; 172 PK11_FreeSlot = NULL;
170 PK11_Authenticate = NULL; 173 PK11_Authenticate = NULL;
171 PK11SDR_Decrypt = NULL; 174 PK11SDR_Decrypt = NULL;
172 SECITEM_FreeItem = NULL; 175 SECITEM_FreeItem = NULL;
173 PL_ArenaFinish = NULL; 176 PL_ArenaFinish = NULL;
174 PR_Cleanup = NULL; 177 PR_Cleanup = NULL;
175 nss3_dll_ = NULL; 178 nss3_dll_ = NULL;
176 softokn3_dll_ = NULL; 179 softokn3_dll_ = NULL;
177 } 180 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698