CID 4383 and 4384: Fix wrong checks of index values against kMaxWorkspaces that

could otherwise lead to out of bound access.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39933 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2010-12-24 02:20:33 +00:00
parent 2e3c20430a
commit 5377c49be4
2 changed files with 5 additions and 5 deletions

View File

@ -673,7 +673,7 @@ Desktop::SetScreenMode(int32 workspace, int32 id, const display_mode& mode,
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 @@ Desktop::GetScreenMode(int32 workspace, int32 id, display_mode& mode)
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 @@ Desktop::GetScreenFrame(int32 workspace, int32 id, BRect& frame)
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) {

View File

@ -610,7 +610,7 @@ DesktopSettingsPrivate::WorkspacesRows() const
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 @@ DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
const BMessage*
DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
{
if (index < 0 || index > kMaxWorkspaces)
if (index < 0 || index >= kMaxWorkspaces)
return NULL;
return &fWorkspaceMessages[index];