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 Jan 29, 2021
1 parent 28d9b3f commit bd84409
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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 bd84409

Please sign in to comment.