Skip to content

Commit

Permalink
Fix #???, address sanitizer failure in FS
Browse files Browse the repository at this point in the history
Add self-defense check in CFE_FS_ParseInputFileNameEx() in case the input
buffer size passed in is greater than the length of the input string.

Technically, this could be argued as an incorrect call/input, but it
is something the function could check for and avoid reading past the
final null char.
  • Loading branch information
jphickey committed Jun 5, 2024
1 parent 505baa1 commit 81a817a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/fs/fsw/src/cfe_fs_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,17 @@ int32 CFE_FS_ParseInputFileNameEx(char *OutputBuffer, const char *InputBuffer, s
/* If input buffer is not empty, then use it, otherwise use DefaultInput */
if (InputBuffer != NULL && InputBufSize > 0 && InputBuffer[0] != 0)
{
InputPtr = memchr(InputBuffer, 0, InputBufSize);
if (InputPtr != NULL)
{
InputLen = InputPtr - InputBuffer;
}
else
{
InputLen = InputBufSize;
}

InputPtr = InputBuffer;
InputLen = InputBufSize;
}
else if (DefaultInput != NULL)
{
Expand Down

0 comments on commit 81a817a

Please sign in to comment.