[haiku-commits] r39933 - haiku/trunk/src/servers/app

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 24 Dec 2010 03:20:33 +0100 (CET)

Author: mmlr
Date: 2010-12-24 03:20:33 +0100 (Fri, 24 Dec 2010)
New Revision: 39933
Changeset: http://dev.haiku-os.org/changeset/39933

Modified:
   haiku/trunk/src/servers/app/Desktop.cpp
   haiku/trunk/src/servers/app/DesktopSettings.cpp
Log:
CID 4383 and 4384: Fix wrong checks of index values against kMaxWorkspaces that
could otherwise lead to out of bound access.


Modified: haiku/trunk/src/servers/app/Desktop.cpp
===================================================================
--- haiku/trunk/src/servers/app/Desktop.cpp     2010-12-24 02:08:54 UTC (rev 
39932)
+++ haiku/trunk/src/servers/app/Desktop.cpp     2010-12-24 02:20:33 UTC (rev 
39933)
@@ -673,7 +673,7 @@
        if (workspace == B_CURRENT_WORKSPACE_INDEX)
                workspace = fCurrentWorkspace;
 
-       if (workspace < 0 || workspace > kMaxWorkspaces)
+       if (workspace < 0 || workspace >= kMaxWorkspaces)
                return B_BAD_VALUE;
 
        Screen* screen = fVirtualScreen.ScreenByID(id);
@@ -742,7 +742,7 @@
        if (workspace == B_CURRENT_WORKSPACE_INDEX)
                workspace = fCurrentWorkspace;
 
-       if (workspace < 0 || workspace > kMaxWorkspaces)
+       if (workspace < 0 || workspace >= kMaxWorkspaces)
                return B_BAD_VALUE;
 
        if (workspace == fCurrentWorkspace) {
@@ -774,7 +774,7 @@
        if (workspace == B_CURRENT_WORKSPACE_INDEX)
                workspace = fCurrentWorkspace;
 
-       if (workspace < 0 || workspace > kMaxWorkspaces)
+       if (workspace < 0 || workspace >= kMaxWorkspaces)
                return B_BAD_VALUE;
 
        if (workspace == fCurrentWorkspace) {

Modified: haiku/trunk/src/servers/app/DesktopSettings.cpp
===================================================================
--- haiku/trunk/src/servers/app/DesktopSettings.cpp     2010-12-24 02:08:54 UTC 
(rev 39932)
+++ haiku/trunk/src/servers/app/DesktopSettings.cpp     2010-12-24 02:20:33 UTC 
(rev 39933)
@@ -610,7 +610,7 @@
 void
 DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
 {
-       if (index < 0 || index > kMaxWorkspaces)
+       if (index < 0 || index >= kMaxWorkspaces)
                return;
 
        fWorkspaceMessages[index] = message;
@@ -620,7 +620,7 @@
 const BMessage*
 DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
 {
-       if (index < 0 || index > kMaxWorkspaces)
+       if (index < 0 || index >= kMaxWorkspaces)
                return NULL;
 
        return &fWorkspaceMessages[index];


Other related posts:

  • » [haiku-commits] r39933 - haiku/trunk/src/servers/app - mmlr