- Fix a bug in timedate.cpl, where an incorrect color was passed.
authorAleksey Bragin <aleksey@reactos.org>
Thu, 12 Jun 2008 09:50:12 +0000 (09:50 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Thu, 12 Jun 2008 09:50:12 +0000 (09:50 +0000)
- Add bounds checking for GetSystemMetrics both in user32 and in kernel counterpart.
- Based on a patch from bug 3316.
See issue #3316 for more details.

svn path=/trunk/; revision=33947

reactos/dll/cpl/timedate/monthcal.c
reactos/dll/win32/user32/misc/desktop.c
reactos/subsystems/win32/win32k/ntuser/metric.c

index 7d7faf9..c764c12 100644 (file)
@@ -504,7 +504,7 @@ MonthCalPaint(IN PMONTHCALWND infoPtr,
             if (crOldCtrlText == CLR_INVALID)
             {
                 crOldCtrlText = SetTextColor(hDC,
-                                             infoPtr->Enabled ? MONTHCAL_CTRLFG : MONTHCAL_DISABLED_CTRLFG);
+                                             GetSysColor(infoPtr->Enabled ? MONTHCAL_CTRLFG : MONTHCAL_DISABLED_CTRLFG));
             }
 
             for (x = prcUpdate->left / infoPtr->CellSize.cx;
index bd7f9ab..04c4bc7 100644 (file)
@@ -100,9 +100,11 @@ int STDCALL
 GetSystemMetrics(int nIndex)
 {
 //  FIXME("Global Sever Data -> %x\n",g_psi);
-  if (g_psi) return g_psi->SystemMetrics[nIndex];
+  if (nIndex < 0 || nIndex >= SM_CMETRICS) return 0;
+  if (g_psi)
+    return g_psi->SystemMetrics[nIndex];
   else
-  return(NtUserGetSystemMetrics(nIndex));
+    return(NtUserGetSystemMetrics(nIndex));
 }
 
 
index ffa41b7..45fe6c7 100644 (file)
@@ -278,6 +278,13 @@ UserGetSystemMetrics(ULONG Index)
    ULONG Width, Height, Result;
 
 //  DPRINT1("UserGetSystemMetrics -> %d\n",Index);
+
+  if (Index >= SM_CMETRICS)
+  {
+     DPRINT1("UserGetSystemMetrics() called with invalid index %d\n", Index);
+     return 0;
+  }
+
   if (gpsi && Setup)
      return gpsi->SystemMetrics[Index];
   else