mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 1178988 - work around PR_ReadDir bug on B2G ICS emulator by loading certs/keys in two phases r=Cykesiopka
This commit is contained in:
parent
427ee2f9c6
commit
9b68248b81
@ -10,6 +10,8 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
|
||||
@ -290,17 +292,32 @@ InitializeNSS(const char* nssCertDBDir)
|
||||
PrintPRError("PR_OpenDir failed");
|
||||
return SECFailure;
|
||||
}
|
||||
// On the B2G ICS emulator, operations taken in AddCertificateFromFile or
|
||||
// AddKeyFromFile appear to interact poorly with PR_ReadDir (more
|
||||
// specifically, something is causing PR_ReadDir to never return null - it
|
||||
// indefinitely loops through every file in the directory, which causes
|
||||
// timeouts). Rather than waste more time chasing this down, loading
|
||||
// certificates and keys happens in two phases: filename collection and then
|
||||
// loading.
|
||||
std::vector<std::string> certificates;
|
||||
std::vector<std::string> keys;
|
||||
for (PRDirEntry* dirEntry = PR_ReadDir(fdDir, PR_SKIP_BOTH); dirEntry;
|
||||
dirEntry = PR_ReadDir(fdDir, PR_SKIP_BOTH)) {
|
||||
size_t nameLength = strlen(dirEntry->name);
|
||||
if (nameLength > 4) {
|
||||
if (strncmp(dirEntry->name + nameLength - 4, ".pem", 4) == 0) {
|
||||
AddCertificateFromFile(basePath, dirEntry->name);
|
||||
certificates.push_back(dirEntry->name);
|
||||
} else if (strncmp(dirEntry->name + nameLength - 4, ".key", 4) == 0) {
|
||||
AddKeyFromFile(basePath, dirEntry->name);
|
||||
keys.push_back(dirEntry->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (std::string& certificate : certificates) {
|
||||
AddCertificateFromFile(basePath, certificate.c_str());
|
||||
}
|
||||
for (std::string& key : keys) {
|
||||
AddKeyFromFile(basePath, key.c_str());
|
||||
}
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user