+2012-02-21 Patrick Gansterer <paroga@webkit.org>
+
+ Use WTF::cryptographicallyRandomValues in FileSystemWin.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=79089
+
+ Reviewed by Adam Roben.
+
+ Avoid loading and unloading of the crypto library during every
+ call to openTemporaryFile() and make the code easier.
+
+ * platform/win/FileSystemWin.cpp:
+ (WebCore::openTemporaryFile):
+
2012-02-21 Alexander Færøy <alexander.faeroy@nokia.com>
Remove stylesheet pointer from StylePropertySet
#include "NotImplemented.h"
#include "PathWalker.h"
+#include <wtf/CryptographicallyRandomNumber.h>
#include <wtf/HashMap.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
if (tempPathLength <= 0 || tempPathLength > WTF_ARRAY_LENGTH(tempPath))
return String();
- HCRYPTPROV hCryptProv = 0;
- if (!CryptAcquireContext(&hCryptProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
- return String();
-
String proposedPath;
do {
wchar_t tempFile[] = L"XXXXXXXX.tmp"; // Use 8.3 style name (more characters aren't helpful due to 8.3 short file names)
const int randomPartLength = 8;
- if (!CryptGenRandom(hCryptProv, randomPartLength * sizeof(wchar_t), reinterpret_cast<BYTE*>(tempFile)))
- break;
+ cryptographicallyRandomValues(tempFile, randomPartLength * sizeof(wchar_t));
// Limit to valid filesystem characters, also excluding others that could be problematic, like punctuation.
// don't include both upper and lowercase since Windows file systems are typically not case sensitive.
handle = ::CreateFileW(proposedPath.charactersWithNullTermination(), GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
} while (!isHandleValid(handle) && GetLastError() == ERROR_ALREADY_EXISTS);
- CryptReleaseContext(hCryptProv, 0);
-
if (!isHandleValid(handle))
return String();