diff options
author | wtchang%redhat.com <devnull@localhost> | 2007-02-23 22:47:53 +0000 |
---|---|---|
committer | wtchang%redhat.com <devnull@localhost> | 2007-02-23 22:47:53 +0000 |
commit | 91d614c9a1cebe1c3a3f6444d28d26ccbca96b3e (patch) | |
tree | 225d1c6c58a61bdc019525c60f18e3aca7a1d362 | |
parent | eedff18c1a5cd5514a346360b99a7a09fd2935fd (diff) | |
download | nss-hg-91d614c9a1cebe1c3a3f6444d28d26ccbca96b3e.tar.gz |
Workaround bogus assertion failure in MSVC 8 (Express, 2005) RTL by switching
from the old _findfirst, _findnext file enumeration API to the newer
FindFirstFile, FindNextFile API. Might be slower, but won't crash if it finds
files older than 1970. Bug 331404. r=julien.pierre,wtc
Tag: NSS_3_11_BRANCH
-rw-r--r-- | security/nss/lib/freebl/win_rand.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/security/nss/lib/freebl/win_rand.c b/security/nss/lib/freebl/win_rand.c index 286ad3522..5c0eff41b 100644 --- a/security/nss/lib/freebl/win_rand.c +++ b/security/nss/lib/freebl/win_rand.c @@ -247,8 +247,8 @@ EnumSystemFiles(PRInt32 (*func)(const char *)) char szSysDir[_MAX_PATH]; char szFileName[_MAX_PATH]; #ifdef _WIN32 - struct _finddata_t fdData; - long lFindHandle; + WIN32_FIND_DATA fdData; + HANDLE lFindHandle; #else struct _find_t fdData; #endif @@ -262,28 +262,27 @@ EnumSystemFiles(PRInt32 (*func)(const char *)) strcat(szFileName, "\\*.*"); #ifdef _WIN32 - lFindHandle = _findfirst(szFileName, &fdData); - if (lFindHandle == -1) + lFindHandle = FindFirstFile(szFileName, &fdData); + if (lFindHandle == INVALID_HANDLE_VALUE) return FALSE; + do { + // pass the full pathname to the callback + sprintf(szFileName, "%s\\%s", szSysDir, fdData.cFileName); + (*func)(szFileName); + iStatus = FindNextFile(lFindHandle, &fdData); + } while (iStatus != 0); + FindClose(lFindHandle); #else - if (_dos_findfirst(szFileName, _A_NORMAL | _A_RDONLY | _A_ARCH | _A_SUBDIR, &fdData) != 0) + if (_dos_findfirst(szFileName, + _A_NORMAL | _A_RDONLY | _A_ARCH | _A_SUBDIR, &fdData) != 0) return FALSE; -#endif - do { // pass the full pathname to the callback sprintf(szFileName, "%s\\%s", szSysDir, fdData.name); (*func)(szFileName); - -#ifdef _WIN32 - iStatus = _findnext(lFindHandle, &fdData); -#else iStatus = _dos_findnext(&fdData); -#endif } while (iStatus == 0); - -#ifdef _WIN32 - _findclose(lFindHandle); + _dos_findclose(&fdData); #endif return TRUE; |