Skip to content

Commit

Permalink
Fix nasa#711, Add msgid max val and update fcncode check
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Aug 7, 2020
1 parent b5467c1 commit 4e15ff2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/msg/src/cfe_msg_msgid_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int32 CFE_MSG_SetMsgId(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId)

CFE_SB_MsgId_Atom_t msgidval = CFE_SB_MsgIdToValue(MsgId);

if (MsgPtr == NULL)
if (MsgPtr == NULL || msgidval > CFE_PLATFORM_SB_HIGHEST_VALID_MSGID)
{
return CFE_MSG_BAD_ARGUMENT;
}
Expand Down
3 changes: 2 additions & 1 deletion modules/msg/src/cfe_msg_msgid_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "cfe_msg_api.h"
#include "cfe_msg_priv.h"
#include "cfe_error.h"
#include "cfe_platform_cfg.h"

/* cFS MsgId definitions */
#define CFE_MSG_MSGID_APID_MASK 0x007F /**< \brief CCSDS ApId mask for MsgId */
Expand Down Expand Up @@ -84,7 +85,7 @@ int32 CFE_MSG_SetMsgId(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId)

CFE_SB_MsgId_Atom_t msgidval = CFE_SB_MsgIdToValue(MsgId);

if (MsgPtr == NULL)
if (MsgPtr == NULL || msgidval > CFE_PLATFORM_SB_HIGHEST_VALID_MSGID)
{
return CFE_MSG_BAD_ARGUMENT;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/msg/src/cfe_msg_sechdr_fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int32 CFE_MSG_SetFcnCode(CFE_MSG_Message_t *MsgPtr, CFE_MSG_FcnCode_t FcnCode)
bool hassechdr = false;
CFE_MSG_CommandHeader_t *cmd = (CFE_MSG_CommandHeader_t *)MsgPtr;

if (MsgPtr == NULL || ((FcnCode & ~CFE_MSG_FC_MASK) != 0))
if (MsgPtr == NULL || (FcnCode > CFE_MSG_FC_MASK))
{
return CFE_MSG_BAD_ARGUMENT;
}
Expand Down

0 comments on commit 4e15ff2

Please sign in to comment.