Skip to content

Commit c16fbee

Browse files
authored
Merge pull request nasa#857 from jphickey/fix-823-cds-reg-find
Fix nasa#823, avoid infinite loop in CDS registry find
2 parents 64f0da9 + 58ed92e commit c16fbee

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

fsw/cfe-core/src/es/cfe_es_cds.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,13 +637,10 @@ int32 CFE_ES_UnlockCDSRegistry(void)
637637
int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
638638
{
639639
int32 RegIndx = CFE_ES_CDS_NOT_FOUND;
640-
int32 i = -1;
640+
uint32 i = 0;
641641

642-
do
642+
while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < CFE_ES_Global.CDSVars.MaxNumRegEntries) )
643643
{
644-
/* Point to next record in the CDS Registry */
645-
i++;
646-
647644
/* Check to see if the record is currently being used */
648645
if (CFE_ES_Global.CDSVars.Registry[i].Taken == true)
649646
{
@@ -654,7 +651,11 @@ int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
654651
RegIndx = i;
655652
}
656653
}
657-
} while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < (CFE_ES_Global.CDSVars.MaxNumRegEntries-1)) );
654+
655+
/* Point to next record in the CDS Registry */
656+
i++;
657+
658+
};
658659

659660
return RegIndx;
660661
} /* End of CFE_ES_FindCDSInRegistry() */
@@ -670,7 +671,7 @@ int32 CFE_ES_FindCDSInRegistry(const char *CDSName)
670671
int32 CFE_ES_FindFreeCDSRegistryEntry(void)
671672
{
672673
int32 RegIndx = CFE_ES_CDS_NOT_FOUND;
673-
int32 i = 0;
674+
uint32 i = 0;
674675

675676
while ( (RegIndx == CFE_ES_CDS_NOT_FOUND) && (i < CFE_ES_Global.CDSVars.MaxNumRegEntries) )
676677
{

0 commit comments

Comments
 (0)