Skip to content

Suggested upper limit value creates infinite loop #414

@impala454

Description

@impala454

When the user sets CFE_PLATFORM_SB_HIGHEST_VALID_MSGID, the documentation specifies a range of 1 to 0xFFFF. This value is later used in a #define in cfe_sb_priv.h as follows:

 #define CFE_SB_MAX_NUMBER_OF_MSG_KEYS   (1+CFE_PLATFORM_SB_HIGHEST_VALID_MSGID)

This value is then used as the upper limit of a for loop here.

The problem is that if the user sets the upper limit of 0xFFFF as specified, the CFE_SB_MAX_NUMBER_OF_MSG_KEYS becomes 65536. This value is used as the upper range of the for loop linked above. Since the iterator used in that loop is a unsigned 16 bit integer, it can never reach 65536 and creates an infinite loop.

Suggested fix would be to:

  1. Stop using #defines which add to other #defines
  2. Never use #defines as iterator range variables
  3. Check types of all iterators
  4. Change the documentation of CFE_PLATFORM_SB_HIGHEST_VALID_MSGID to say max value of 0xFFFE

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions