-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some functions missing range check on AtsNumber #118
Labels
Comments
As a side note, it is worth mentioning that the corresponding Its a case where the coverage test is invoking this function in a state where it would never be invoked during normal FSW operation. |
jphickey
added a commit
to jphickey/SC
that referenced
this issue
Nov 9, 2023
Adds inline functions to do range checking, and uses them in all places where the same logic had been copied around. This reduces repetition of logic. Introduces proper data types and wrapper functions to deal with the different types of IDs and indices.
2 tasks
jphickey
added a commit
to jphickey/SC
that referenced
this issue
Nov 9, 2023
Adds inline functions to do range checking, and uses them in all places where the same logic had been copied around. This reduces repetition of logic. Introduces proper data types and wrapper functions to deal with the different types of IDs and indices.
jphickey
added a commit
to jphickey/SC
that referenced
this issue
Nov 9, 2023
Adds inline functions to do range checking, and uses them in all places where the same logic had been copied around. This reduces repetition of logic. Introduces proper data types and wrapper functions to deal with the different types of IDs and indices.
jphickey
added a commit
to jphickey/SC
that referenced
this issue
Nov 9, 2023
Adds inline functions to do range checking, and uses them in all places where the same logic had been copied around. This reduces repetition of logic. Introduces proper data types and wrapper functions to deal with the different types of IDs and indices.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Checklist (Please check before submitting)
Describe the bug
The
SC_KillAts()
function does not do a range-check on theAtsNumber
. In the case that the number is 0, this will end up accessing an invalid array index.To Reproduce
This is actually done by the unit test code, it calls SC_KillAts() with the AtsNumber set to 0. However, by chance, it doesn't segfault - merely because the value is a uint8, therefore with the wrap-around it only attempts to access array index 255, which is likely to be on the same memory page. It does, however, corrupt some other memory by doing so.
Expected behavior
Should range check, should not access invalid memory locations
Code snips
SC/fsw/src/sc_atsrq.c
Line 277 in 7587a8c
There is a lot going on in this one line of code - it should be split up. But in particular, the
SC_ATS_NUM_TO_INDEX
subtracts 1, so if the AtsNumber is 0, this will end up accessing an invalid array index.System observed on:
Debian
Additional context
The
SC_SwitchAtsCmd()
(and in particular theSC_ToggleAtsIndex()
used by it) also have a similar problem.Reporter Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: