Skip to content

Fix #823, avoid infinite loop in CDS registry find#857

Merged
yammajamma merged 1 commit intonasa:integration-candidatefrom
jphickey:fix-823-cds-reg-find
Sep 2, 2020
Merged

Fix #823, avoid infinite loop in CDS registry find#857
yammajamma merged 1 commit intonasa:integration-candidatefrom
jphickey:fix-823-cds-reg-find

Conversation

@jphickey
Copy link
Contributor

@jphickey jphickey commented Sep 2, 2020

Describe the contribution
The CFE_ES_FindCDSInRegistry function had an unusual loop control structure with mixed types of signed and unsigned. This has the possibility of being infinite if the MaxNumRegEntries is zero due to the way the end condition is structured. Simplify to be like other loops and use unsigned int control variable.

Fixes #823

Testing performed
Build and sanity check CFE
Run all unit tests

Expected behavior changes
No impact to behavior so long as CFE was configured where the number of CDS entries is not zero.
If configured to be zero, this avoids an infinite loop.

System(s) tested on
Ubuntu 20.04

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

The CFE_ES_FindCDSInRegistry function had an unusual loop control
structure with mixed types of signed and unsigned.

This has the possibility of being infinite if the MaxNumRegEntries
is zero due to the way the end condition is structured.

Simplify to be like other loops and use unsigned int control variable.
} while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < (CFE_ES_Global.CDSVars.MaxNumRegEntries-1)) );

/* Point to next record in the CDS Registry */
i++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to do a for loop with a break?

@astrogeco
Copy link
Contributor

CCB 2020-09-02 APPROVED

@yammajamma yammajamma changed the base branch from main to integration-candidate September 2, 2020 19:01
@yammajamma yammajamma added IC-20200902 CCB:Approved Indicates code review and approval by community CCB labels Sep 2, 2020
@yammajamma yammajamma merged commit c16fbee into nasa:integration-candidate Sep 2, 2020
@jphickey jphickey deleted the fix-823-cds-reg-find branch September 29, 2020 21:52
@skliper skliper added this to the 7.0.0 milestone Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CCB:Approved Indicates code review and approval by community CCB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CFE_ES_FindCDSInRegistry() infinte loop if registry size is zero

4 participants