Author: janderwald
Date: Tue Apr 29 05:27:03 2008
New Revision: 33187
URL:
http://svn.reactos.org/svn/reactos?rev=33187&view=rev
Log:
- query current time zone
- retrieve localized country for a version
- pass length parameter to avoid potential buffer overflows
Modified:
trunk/reactos/base/applications/dxdiag/display.c
trunk/reactos/base/applications/dxdiag/network.c
trunk/reactos/base/applications/dxdiag/precomp.h
Modified: trunk/reactos/base/applications/dxdiag/display.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/dxdiag/d…
==============================================================================
--- trunk/reactos/base/applications/dxdiag/display.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/dxdiag/display.c [iso-8859-1] Tue Apr 29 05:27:03
2008
@@ -18,6 +18,7 @@
FILETIME AccessTime;
SYSTEMTIME SysTime, LocalTime;
UINT Length;
+ TIME_ZONE_INFORMATION TimeInfo;
hFile = CreateFileW(pFullPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if (!hFile)
@@ -30,10 +31,13 @@
}
CloseHandle(hFile);
+ if(!GetTimeZoneInformation(&TimeInfo))
+ return FALSE;
+
if (!FileTimeToSystemTime(&AccessTime, &SysTime))
return FALSE;
- if (!SystemTimeToTzSpecificLocalTime(NULL, &SysTime, &LocalTime))
+ if (!SystemTimeToTzSpecificLocalTime(&TimeInfo, &SysTime, &LocalTime))
return FALSE;
Length = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &LocalTime, NULL,
szTime, szTimeSize);
@@ -82,7 +86,7 @@
else
{
/* set file version */
- if (GetFileVersion(pFullPath, szVer))
+ if (GetFileVersion(pFullPath, szVer, sizeof(szVer)/sizeof(WCHAR)))
SendMessageW(hDlgCtrls[1], WM_SETTEXT, 0, (LPARAM)szVer);
/* set file time */
if (GetFileModifyTime(pFullPath, szVer, sizeof(szVer)/sizeof(WCHAR)))
Modified: trunk/reactos/base/applications/dxdiag/network.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/dxdiag/n…
==============================================================================
--- trunk/reactos/base/applications/dxdiag/network.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/dxdiag/network.c [iso-8859-1] Tue Apr 29 05:27:03
2008
@@ -100,7 +100,7 @@
}
BOOL
-GetFileVersion(LPCWSTR szAppName, WCHAR * szVer)
+GetFileVersion(LPCWSTR szAppName, WCHAR * szVer, DWORD szVerSize)
{
UINT VerSize;
DWORD DummyHandle;
@@ -150,9 +150,14 @@
pResult = NULL;
bResult = VerQueryValueW(pBuf, szBuffer, (LPVOID *)&pResult, &VerSize);
- if (VerSize && bResult && pResult)
+ if (VerSize < szVerSize && bResult && pResult)
{
wcscpy(szVer, pResult);
+ if (GetLocaleInfoW(MAKELCID(lang, SORT_DEFAULT), LOCALE_SLANGUAGE,
&szVer[VerSize], szVerSize-VerSize))
+ {
+ szVer[VerSize-1] = L' ';
+ szVer[szVerSize-1] = L'\0';
+ }
bResult = TRUE;
}
@@ -254,7 +259,7 @@
Item.iItem = ProviderIndex + ItemCount;
SendMessageW(hDlgCtrl, LVM_SETITEM, 0, (LPARAM)&Item);
/* retrieve file version */
- if (!GetFileVersion(szResult, szTemp))
+ if (!GetFileVersion(szResult, szTemp, sizeof(szTemp)/sizeof(WCHAR)))
{
szTemp[0] = L'\0';
LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTemp,
sizeof(szTemp)/sizeof(WCHAR));
Modified: trunk/reactos/base/applications/dxdiag/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/dxdiag/p…
==============================================================================
--- trunk/reactos/base/applications/dxdiag/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/dxdiag/precomp.h [iso-8859-1] Tue Apr 29 05:27:03
2008
@@ -43,6 +43,6 @@
BOOL StartDDTest(HWND hWnd, HINSTANCE hInstance, INT resTestDescription, INT resResult,
INT TestNr);
-BOOL GetFileVersion(LPCWSTR szAppName, WCHAR * szVer);
+BOOL GetFileVersion(LPCWSTR szAppName, WCHAR * szVer, DWORD szVerSize);
BOOL GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize);
#endif