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:
@@ -673,7 +673,7 @@ Desktop::SetScreenMode(int32 workspace, int32 id, const display_mode& mode,
|
|||||||
if (workspace == B_CURRENT_WORKSPACE_INDEX)
|
if (workspace == B_CURRENT_WORKSPACE_INDEX)
|
||||||
workspace = fCurrentWorkspace;
|
workspace = fCurrentWorkspace;
|
||||||
|
|
||||||
if (workspace < 0 || workspace > kMaxWorkspaces)
|
if (workspace < 0 || workspace >= kMaxWorkspaces)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
Screen* screen = fVirtualScreen.ScreenByID(id);
|
Screen* screen = fVirtualScreen.ScreenByID(id);
|
||||||
@@ -742,7 +742,7 @@ Desktop::GetScreenMode(int32 workspace, int32 id, display_mode& mode)
|
|||||||
if (workspace == B_CURRENT_WORKSPACE_INDEX)
|
if (workspace == B_CURRENT_WORKSPACE_INDEX)
|
||||||
workspace = fCurrentWorkspace;
|
workspace = fCurrentWorkspace;
|
||||||
|
|
||||||
if (workspace < 0 || workspace > kMaxWorkspaces)
|
if (workspace < 0 || workspace >= kMaxWorkspaces)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (workspace == fCurrentWorkspace) {
|
if (workspace == fCurrentWorkspace) {
|
||||||
@@ -774,7 +774,7 @@ Desktop::GetScreenFrame(int32 workspace, int32 id, BRect& frame)
|
|||||||
if (workspace == B_CURRENT_WORKSPACE_INDEX)
|
if (workspace == B_CURRENT_WORKSPACE_INDEX)
|
||||||
workspace = fCurrentWorkspace;
|
workspace = fCurrentWorkspace;
|
||||||
|
|
||||||
if (workspace < 0 || workspace > kMaxWorkspaces)
|
if (workspace < 0 || workspace >= kMaxWorkspaces)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (workspace == fCurrentWorkspace) {
|
if (workspace == fCurrentWorkspace) {
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ DesktopSettingsPrivate::WorkspacesRows() const
|
|||||||
void
|
void
|
||||||
DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
|
DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
|
||||||
{
|
{
|
||||||
if (index < 0 || index > kMaxWorkspaces)
|
if (index < 0 || index >= kMaxWorkspaces)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fWorkspaceMessages[index] = message;
|
fWorkspaceMessages[index] = message;
|
||||||
@@ -620,7 +620,7 @@ DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
|
|||||||
const BMessage*
|
const BMessage*
|
||||||
DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
|
DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
|
||||||
{
|
{
|
||||||
if (index < 0 || index > kMaxWorkspaces)
|
if (index < 0 || index >= kMaxWorkspaces)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return &fWorkspaceMessages[index];
|
return &fWorkspaceMessages[index];
|
||||||
|
|||||||
Reference in New Issue
Block a user