Print Page | Close Window

Possible Error in XTPCommandBar?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: General Discussion
Forum Description: Topics Related to Visual C++ MFC Development in General
URL: http://forum.codejock.com/forum_posts.asp?TID=6384
Printed Date: 31 January 2025 at 4:03am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Possible Error in XTPCommandBar?
Posted By: skemp@docucorp
Subject: Possible Error in XTPCommandBar?
Date 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.




Replies:
Posted By: Oleg
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net