[TASKMGR]
authorKamil Hornicek <kamil.hornicek@reactos.org>
Wed, 22 Oct 2014 16:01:24 +0000 (16:01 +0000)
committerKamil Hornicek <kamil.hornicek@reactos.org>
Wed, 22 Oct 2014 16:01:24 +0000 (16:01 +0000)
- fix CIDs 731628 (unlikely buffer overrun), 500038 (dead code), 1101977 (unchecked return value)

svn path=/trunk/; revision=64890

reactos/base/applications/taskmgr/column.c
reactos/base/applications/taskmgr/graphctl.c
reactos/base/applications/taskmgr/graphctl.h
reactos/base/applications/taskmgr/taskmgr.c

index 961287b..093f783 100644 (file)
@@ -204,10 +204,13 @@ void UpdateColumnDataHints(void)
     HDITEM        hditem;
     WCHAR         text[260];
     ULONG         Index;
+    ULONG         uItems;
     WCHAR         szTemp[256];
-    unsigned int  i;
+    UINT          i;
+
+    uItems = min(SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0), COLUMN_NMAX);
 
-    for (Index=0; Index<(ULONG)SendMessageW(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); Index++)
+    for (Index=0; Index<uItems; Index++)
     {
         memset(&hditem, 0, sizeof(HDITEM));
 
index d7f961c..71f8d67 100644 (file)
@@ -120,17 +120,15 @@ void GraphCtrl_Dispose(TGraphCtrl* this)
     if (this->m_brushBack     != NULL) DeleteObject(this->m_brushBack);
 }
 
-BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID)
+void GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID)
 {
-    BOOL result = 0;
-
     GraphCtrl_Init(this);
     this->m_hParentWnd = hParentWnd;
     this->m_hWnd = hWnd;
+
     GraphCtrl_Resize(this);
-    if (result != 0)
-        GraphCtrl_InvalidateCtrl(this, FALSE);
-    return result;
+
+    return;
 }
 
 void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDecimalPlaces)
index 3a5b838..e9ef84f 100644 (file)
@@ -88,7 +88,7 @@ extern WNDPROC OldGraphCtrlWndProc;
 double  GraphCtrl_AppendPoint(TGraphCtrl* this,
                               double dNewPoint0, double dNewPoint1,
                               double dNewPoint2, double dNewPoint3);
-BOOL    GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd,
+void    GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd,
 UINT nID);
 void    GraphCtrl_Dispose(TGraphCtrl* this);
 void    GraphCtrl_DrawPoint(TGraphCtrl* this);
index 36192dc..7cb8aef 100644 (file)
@@ -154,13 +154,14 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
     /* Get a token for this process.  */
     if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
         /* Get the LUID for the debug privilege.  */
-        LookupPrivilegeValueW(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid);
-
-        tkp.PrivilegeCount = 1;  /* one privilege to set */
-        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+        if(LookupPrivilegeValueW(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid))
+        {
+            tkp.PrivilegeCount = 1;  /* one privilege to set */
+            tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
 
-        /* Get the debug privilege for this process. */
-        AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
+            /* Get the debug privilege for this process. */
+            AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
+        }
         CloseHandle(hToken);
     }