-
Notifications
You must be signed in to change notification settings - Fork 234
Labels
Milestone
Description
Describe the bug
Counter variable, i, is modified inside the for loop, which may lead to an infinite loop. Should use while loop instead.
Location
root/cfe/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c
lines 1373 - 1380
Expected behavior
Use while loop or add comments explaining the reasoning of using for loop for future developers (must ensure loop issues will not occur such as the code looping infinitely). If using while loop, please provide maximum limit for counter.
Code snips
cFE/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c
Lines 1373 to 1380 in a148b97
| for (i=0; i<CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES; i++) | |
| { | |
| if (strncmp(CFE_TBL_TaskData.CritReg[i].Name, TableName, CFE_TBL_MAX_FULL_NAME_LEN) == 0) | |
| { | |
| CritRegRecPtr = &CFE_TBL_TaskData.CritReg[i]; | |
| i=CFE_PLATFORM_TBL_MAX_CRITICAL_TABLES; | |
| } | |
| } |
Additional context
References: https://help.semmle.com/wiki/display/CCPPOBJ/For+loop+variable+changed+in+body
Reporter Info
Ariel Adams, ASRC Federal