Skip to content

Commit

Permalink
Fix #546, add argument validation
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed Feb 2, 2021
1 parent 28d9b3f commit be35514
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/es/cfe_es_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferL
int32 Result;
CFE_ES_AppRecord_t *AppRecPtr;

if (BufferLength == 0 || AppName == NULL)
if (BufferLength == 0 || AppName == NULL || BufferLength > OS_MAX_API_NAME)
{
return CFE_ES_BAD_ARGUMENT;
}
Expand Down
6 changes: 6 additions & 0 deletions fsw/cfe-core/src/sb/cfe_sb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,12 @@ CFE_SB_Buffer_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize,
CFE_SB_ZeroCopyD_t *zcd = NULL;
CFE_SB_BufferD_t *bd = NULL;

if(MsgSize > CFE_MISSION_SB_MAX_SB_MSG_SIZE)
{
CFE_ES_WriteToSysLog(" CFE_SB:ZeroCopyGetPtr-Failed, MsgSize is too large\n");
return NULL;
}

CFE_SB_LockSharedData(__func__,__LINE__);

/* Allocate a new zero copy descriptor from the SB memory pool.*/
Expand Down
8 changes: 7 additions & 1 deletion fsw/cfe-core/src/sb/cfe_sb_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ void CFE_SB_SetUserDataLength(CFE_MSG_Message_t *MsgPtr, size_t DataLength)
HdrSize = CFE_SB_MsgHdrSize(MsgPtr);
TotalMsgSize = HdrSize + DataLength;

CFE_MSG_SetSize(MsgPtr, TotalMsgSize);
if(TotalMsgSize <= CFE_MISSION_SB_MAX_SB_MSG_SIZE){
CFE_MSG_SetSize(MsgPtr, TotalMsgSize);
}
else
{
CFE_ES_WriteToSysLog("CFE_SB:SetUserDataLength-Failed TotalMsgSize too large\n");
}
}
}/* end CFE_SB_SetUserDataLength */

Expand Down

0 comments on commit be35514

Please sign in to comment.