Bug 1271953 - Remove nss_addEscape(). r=mgoodwin

The function basically duplicates existing Mozilla string class functionality.

MozReview-Commit-ID: 9IFEXuT9cW1

--HG--
extra : rebase_source : 0d0c4492a63f7a168b6092fdb2e1bf8ec09d5308
This commit is contained in:
Cykesiopka 2016-05-16 09:04:09 -07:00
Родитель def695bf98
Коммит 1d22abcec2
1 изменённых файлов: 5 добавлений и 37 удалений

Просмотреть файл

@ -959,40 +959,6 @@ NSSCertDBTrustDomain::NetscapeStepUpMatchesServerAuth(Time notBefore,
return Result::FATAL_ERROR_LIBRARY_FAILURE;
}
namespace {
static char*
nss_addEscape(const char* string, char quote)
{
char* newString = 0;
size_t escapes = 0, size = 0;
const char* src;
char* dest;
for (src = string; *src; src++) {
if ((*src == quote) || (*src == '\\')) {
escapes++;
}
size++;
}
newString = (char*) PORT_ZAlloc(escapes + size + 1u);
if (!newString) {
return nullptr;
}
for (src = string, dest = newString; *src; src++, dest++) {
if ((*src == quote) || (*src == '\\')) {
*dest++ = '\\';
}
*dest = *src;
}
return newString;
}
} // unnamed namespace
SECStatus
InitializeNSS(const char* dir, bool readOnly, bool loadPKCS11Modules)
{
@ -1038,9 +1004,11 @@ LoadLoadableRoots(/*optional*/ const char* dir, const char* modNameUTF8)
return SECFailure;
}
UniquePORTString escapedFullLibraryPath(nss_addEscape(fullLibraryPath.get(),
'\"'));
if (!escapedFullLibraryPath) {
// Escape the \ and " characters.
nsAutoCString escapedFullLibraryPath(fullLibraryPath.get());
escapedFullLibraryPath.ReplaceSubstring("\\", "\\\\");
escapedFullLibraryPath.ReplaceSubstring("\"", "\\\"");
if (escapedFullLibraryPath.IsEmpty()) {
return SECFailure;
}