Title: [108353] trunk/Source/WebCore
- Revision
- 108353
- Author
- [email protected]
- Date
- 2012-02-21 07:52:06 -0800 (Tue, 21 Feb 2012)
Log Message
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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (108352 => 108353)
--- trunk/Source/WebCore/ChangeLog 2012-02-21 15:31:14 UTC (rev 108352)
+++ trunk/Source/WebCore/ChangeLog 2012-02-21 15:52:06 UTC (rev 108353)
@@ -1,3 +1,16 @@
+2012-02-21 Patrick Gansterer <[email protected]>
+
+ 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 <[email protected]>
Remove stylesheet pointer from StylePropertySet
Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (108352 => 108353)
--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp 2012-02-21 15:31:14 UTC (rev 108352)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp 2012-02-21 15:52:06 UTC (rev 108353)
@@ -32,6 +32,7 @@
#include "NotImplemented.h"
#include "PathWalker.h"
+#include <wtf/CryptographicallyRandomNumber.h>
#include <wtf/HashMap.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
@@ -220,16 +221,11 @@
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.
@@ -247,8 +243,6 @@
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();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes