Skip to content

Commit

Permalink
Fix nasa#1330, better warning about malformed startup line
Browse files Browse the repository at this point in the history
This improves the log message when a line in the startup script is
not formed correctly, such as being too long or having too many
tokens.
  • Loading branch information
jphickey committed Apr 16, 2021
1 parent e80aae9 commit 5660575
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions modules/es/fsw/src/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath)
char ScriptFileName[OS_MAX_PATH_LEN];
const char *TokenList[CFE_ES_STARTSCRIPT_MAX_TOKENS_PER_LINE];
uint32 NumTokens;
uint32 NumLines;
uint32 BuffLen; /* Length of the current buffer */
osal_id_t AppFile = OS_OBJECT_ID_UNDEFINED;
int32 Status;
Expand Down Expand Up @@ -151,6 +152,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath)
memset(ES_AppLoadBuffer, 0x0, ES_START_BUFF_SIZE);
BuffLen = 0;
NumTokens = 0;
NumLines = 0;
TokenList[0] = ES_AppLoadBuffer;

/*
Expand Down Expand Up @@ -197,14 +199,18 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath)
}
BuffLen++;

if (NumTokens < (CFE_ES_STARTSCRIPT_MAX_TOKENS_PER_LINE - 1))
++NumTokens;
if (NumTokens < CFE_ES_STARTSCRIPT_MAX_TOKENS_PER_LINE)
{
/*
* NOTE: pointer never deferenced unless "LineTooLong" is false.
*/
++NumTokens;
TokenList[NumTokens] = &ES_AppLoadBuffer[BuffLen];
}
else
{
LineTooLong = true;
}
}
else if (c != ';')
{
Expand All @@ -223,13 +229,15 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath)
}
else
{
++NumLines;

if (LineTooLong == true)
{
/*
** The was too big for the buffer
** The line was not formed correctly
*/
CFE_ES_WriteToSysLog("ES Startup: ES Startup File Line is too long: %u bytes.\n",
(unsigned int)BuffLen);
CFE_ES_WriteToSysLog("ES Startup: **WARNING** File Line %u is malformed: %u bytes, %u tokens.\n",
(unsigned int)NumLines, (unsigned int)BuffLen, (unsigned int)NumTokens);
LineTooLong = false;
}
else
Expand Down

0 comments on commit 5660575

Please sign in to comment.