Skip to content

Commit

Permalink
Fix #2529, Adds snprintf check return value in EVS_SendViaPorts
Browse files Browse the repository at this point in the history
  • Loading branch information
jdfiguer authored and jdfiguer committed Jun 12, 2024
1 parent 505baa1 commit b0d1ee1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/evs/fsw/src/cfe_evs_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#define CFE_EVS_MAX_FILTER_COUNT 65535
#define CFE_EVS_MAX_SQUELCH_COUNT 255
#define CFE_EVS_PIPE_NAME "EVS_CMD_PIPE"
#define CFE_EVS_MAX_PORT_MSG_LENGTH (CFE_MISSION_EVS_MAX_MESSAGE_LENGTH + OS_MAX_API_NAME + 30)
#define CFE_EVS_MAX_PORT_MSG_LENGTH (CFE_MISSION_EVS_MAX_MESSAGE_LENGTH + OS_MAX_API_NAME + 19)

/* Since CFE_EVS_MAX_PORT_MSG_LENGTH is the size of the buffer that is sent to
* print out (using OS_printf), we need to check to make sure that the buffer
Expand All @@ -70,6 +70,14 @@
#error CFE_EVS_MAX_PORT_MSG_LENGTH cannot be greater than OS_BUFFER_SIZE!
#endif

/* The buffer needs to have at least 11 extra characters to accommodate the format
* string "EVS Port%u %s\n" used in downstream processing for sending messages via ports.
* If the difference between OS_BUFFER_SIZE and CFE_EVS_MAX_PORT_MSG_LENGTH is less than 11,
* it could result in the truncation of the new line character appended downstream. */
#if OS_BUFFER_SIZE - CFE_EVS_MAX_PORT_MSG_LENGTH < 11
#error CFE_EVS_MAX_PORT_MSG_LENGTH too long; may truncate newline character!
#endif

/************************ Internal Structure Definitions *****************************/

typedef struct
Expand Down

0 comments on commit b0d1ee1

Please sign in to comment.