Skip to content

Commit

Permalink
Merge pull request nasa#857 from jphickey/fix-823-cds-reg-find
Browse files Browse the repository at this point in the history
Fix nasa#823, avoid infinite loop in CDS registry find
  • Loading branch information
yammajamma authored Sep 2, 2020
2 parents 64f0da9 + 58ed92e commit c16fbee
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions fsw/cfe-core/src/es/cfe_es_cds.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,10 @@ int32 CFE_ES_UnlockCDSRegistry(void)
int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
{
int32 RegIndx = CFE_ES_CDS_NOT_FOUND;
int32 i = -1;
uint32 i = 0;

do
while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < CFE_ES_Global.CDSVars.MaxNumRegEntries) )
{
/* Point to next record in the CDS Registry */
i++;

/* Check to see if the record is currently being used */
if (CFE_ES_Global.CDSVars.Registry[i].Taken == true)
{
Expand All @@ -654,7 +651,11 @@ int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
RegIndx = i;
}
}
} while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < (CFE_ES_Global.CDSVars.MaxNumRegEntries-1)) );

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

};

return RegIndx;
} /* End of CFE_ES_FindCDSInRegistry() */
Expand All @@ -670,7 +671,7 @@ int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
int32 CFE_ES_FindFreeCDSRegistryEntry(void)
{
int32 RegIndx = CFE_ES_CDS_NOT_FOUND;
int32 i = 0;
uint32 i = 0;

while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < CFE_ES_Global.CDSVars.MaxNumRegEntries) )
{
Expand Down

0 comments on commit c16fbee

Please sign in to comment.