Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > General Discussion
  New Posts New Posts RSS Feed - Possible Error in XTPCommandBar?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Possible Error in XTPCommandBar?

 Post Reply Post Reply
Author
Message
skemp@docucorp View Drop Down
Newbie
Newbie


Joined: 08 August 2006
Location: United States
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote skemp@docucorp Quote  Post ReplyReply Direct Link To This Post Topic: Possible Error in XTPCommandBar?
    Posted: 12 February 2007 at 2:26pm
We've recently evaluated a development tool that is supposed to help identify potential programming errors. The following item was found within your framework headers.

Please look at this and let us know what you think.

Buffer overflow, array index of 'm_pDocks' may be outside the bounds. Array 'm_pDocks' of size 4 declared at line 1354 may use index values 4..7

CommandBars\XTPCommandBars.h

1404 AFX_INLINE CXTPDockBar* CXTPCommandBars::GetDockBar(XTPBarPosition xtpPosition) const {

1405 return m_pDocks[xtpPosition];

1406 }

If we examine the m_pDocks declaration, we can see that it is an array of 4 elements.

CommandBars\XTPCommandBars.h

1354 CXTPDockBar* m_pDocks[4]; // DockBars list

If we examine the XTPBarPosition declaration (parameter to GetDockBar), we can see that it is an enum declaration from 0 to 7.

CommandBars\XTPCommandBarsDefines.h

47 enum XTPBarPosition

48 {

49 xtpBarTop = 0, // Docked at top.

50 xtpBarBottom = 1, // Docked at bottom.

51 xtpBarLeft = 2, // Docked at left.

52 xtpBarRight = 3, // Docked at right.

53 xtpBarFloating = 4, // Floated.

54 xtpBarPopup = 5, // Popup.

55 xtpBarListBox = 6, // List box.

56 xtpBarNone = 7 // None.

57 };

Using any of the enum values from 4 to 7 would cause an out of bounds condition on the array.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 13 February 2007 at 7:47am
Hello,
When we call it we assume toolbar is docked. But agree, that we have add some check for developers how we call this method outside of library. Added ASSERT.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.