Skip to content

Commit

Permalink
Fix #121, add extra range checking
Browse files Browse the repository at this point in the history
Adds additional range checks to avoid out-of-bounds array access
  • Loading branch information
jphickey committed Nov 9, 2023
1 parent 3fd6345 commit ee21c30
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fsw/src/sc_atsrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ bool SC_BeginAts(SC_AtsIndex_t AtsIndex, uint16 TimeOffset)
{
/* first get the cmd index at this list entry */
CmdIndex = SC_CommandNumToIndex(SC_GetAtsCommandNumAtSeq(AtsIndex, TimeIndex)->CmdNum);
if (!SC_AtsCommandIndexIsValid(CmdIndex))
{
SC_IDX_INCREMENT(TimeIndex);
continue;
}

/* then get the entry index from the cmd index table */
CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, CmdIndex);
/* then get a pointer to the ATS entry data */
Expand Down Expand Up @@ -540,6 +546,12 @@ void SC_JumpAtsCmd(const SC_JumpAtsCmd_t *Cmd)
{
/* first get the cmd index at this list entry */
CmdIndex = SC_CommandNumToIndex(SC_GetAtsCommandNumAtSeq(AtsIndex, TimeIndex)->CmdNum);
if (!SC_AtsCommandIndexIsValid(CmdIndex))
{
SC_IDX_INCREMENT(TimeIndex);
continue;
}

/* then get the entry index from the cmd index table */
CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, CmdIndex);
/* then get a pointer to the ATS entry data */
Expand Down

0 comments on commit ee21c30

Please sign in to comment.