Author: cfinck
Date: Sun Jul 22 23:31:29 2007
New Revision: 27781
URL:
http://svn.reactos.org/svn/reactos?rev=27781&view=rev
Log:
- Bugfix: As szBuf was not null-terminated after the _tcscpy, the Processor Name String
could have been wrapped wrong (ie. when it contained more spaces after character 30)
- Use a consistent indentation in SetProcNameString
Modified:
trunk/reactos/dll/cpl/sysdm/general.c
Modified: trunk/reactos/dll/cpl/sysdm/general.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/general.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/general.c (original)
+++ trunk/reactos/dll/cpl/sysdm/general.c Sun Jul 22 23:31:29 2007
@@ -5,7 +5,7 @@
* PURPOSE: General System Information
* COPYRIGHT: Copyright Thomas Weidenmueller <w3seek(a)reactos.org>
* Copyright 2006 Ged Murphy <gedmurphy(a)gmail.com>
- * Copyright 2006 Colin Finck <mail(a)colinfinck.de>
+ * Copyright 2006-2007 Colin Finck <mail(a)colinfinck.de>
*
*/
@@ -118,83 +118,86 @@
UINT uID1,
UINT uID2)
{
- LPTSTR lpBuf = NULL;
- DWORD BufSize = 0;
- DWORD Type;
- INT Ret = 0;
- TCHAR szBuf[31];
- TCHAR* szLastSpace;
- INT LastSpace = 0;
-
- if (RegQueryValueEx(hKey,
- Value,
- NULL,
- &Type,
- NULL,
- &BufSize) == ERROR_SUCCESS)
- {
- lpBuf = HeapAlloc(GetProcessHeap(),
- 0,
- BufSize);
- if (!lpBuf) return 0;
-
- if (RegQueryValueEx(hKey,
- Value,
- NULL,
- &Type,
- (PBYTE)lpBuf,
- &BufSize) == ERROR_SUCCESS)
- {
- if(BufSize > ((30 + 1) * sizeof(TCHAR)))
- {
- /* Wrap the Processor Name String like XP does:
*
- * - Take the first 30 characters and look for the last space.
*
- * Then wrap the string after this space.
*
- * - If no space is found, wrap the string after character 30.
*
- *
*
- * For example the Processor Name String of a Pentium 4 is right-aligned.
*
- * With this wrapping the first line looks centered.
*/
-
- _tcsncpy(szBuf, lpBuf, 30);
- szLastSpace = _tcsrchr(szBuf, ' ');
-
- if(szLastSpace == 0)
- LastSpace = 30;
- else
- LastSpace = (szLastSpace - szBuf);
-
- _tcsncpy(szBuf, lpBuf, LastSpace);
- szBuf[LastSpace] = 0;
-
- SetDlgItemText(hwnd,
- uID1,
- szBuf);
-
- SetDlgItemText(hwnd,
- uID2,
- lpBuf+LastSpace+1);
-
- /* Return the number of used lines */
- Ret = 2;
- }
- else
- {
- SetDlgItemText(hwnd,
- uID1,
- lpBuf);
-
- Ret = 1;
- }
- }
-
- HeapFree(GetProcessHeap(),
- 0,
- lpBuf);
-
- return Ret;
- }
-
- return 0;
+ LPTSTR lpBuf = NULL;
+ DWORD BufSize = 0;
+ DWORD Type;
+ INT Ret = 0;
+ TCHAR szBuf[31];
+ TCHAR* szLastSpace;
+ INT LastSpace = 0;
+
+ if (RegQueryValueEx(hKey,
+ Value,
+ NULL,
+ &Type,
+ NULL,
+ &BufSize) == ERROR_SUCCESS)
+ {
+ lpBuf = HeapAlloc(GetProcessHeap(),
+ 0,
+ BufSize);
+ if (!lpBuf) return 0;
+
+ if (RegQueryValueEx(hKey,
+ Value,
+ NULL,
+ &Type,
+ (PBYTE)lpBuf,
+ &BufSize) == ERROR_SUCCESS)
+ {
+ if(BufSize > ((30 + 1) * sizeof(TCHAR)))
+ {
+ /* Wrap the Processor Name String like XP does: *
+ * - Take the first 30 characters and look for the last space. *
+ * Then wrap the string after this space. *
+ * - If no space is found, wrap the string after character 30. *
+ * *
+ * For example the Processor Name String of a Pentium 4 is right-aligned. *
+ * With this wrapping the first line looks centered. */
+
+ _tcsncpy(szBuf, lpBuf, 30);
+ szBuf[30] = 0;
+ szLastSpace = _tcsrchr(szBuf, ' ');
+
+ if(szLastSpace == 0)
+ LastSpace = 30;
+ else
+ {
+ LastSpace = (szLastSpace - szBuf);
+ szBuf[LastSpace] = 0;
+ }
+
+ _tcsncpy(szBuf, lpBuf, LastSpace);
+
+ SetDlgItemText(hwnd,
+ uID1,
+ szBuf);
+
+ SetDlgItemText(hwnd,
+ uID2,
+ lpBuf+LastSpace+1);
+
+ /* Return the number of used lines */
+ Ret = 2;
+ }
+ else
+ {
+ SetDlgItemText(hwnd,
+ uID1,
+ lpBuf);
+
+ Ret = 1;
+ }
+ }
+
+ HeapFree(GetProcessHeap(),
+ 0,
+ lpBuf);
+
+ return Ret;
+ }
+
+ return 0;
}
static VOID