Skip to content

Commit

Permalink
Fix nasa#1270: Truncate symbol name if > OS_MAX_SYM_LEN
Browse files Browse the repository at this point in the history
  • Loading branch information
dmknutsen committed Nov 16, 2022
1 parent e98bb23 commit 2ae7d7d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/os/vxworks/src/os-impl-symtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,20 @@ BOOL OS_SymTableIterator_Impl(char *name, SYM_VALUE val, SYM_TYPE type, _Vx_usr_
*/
state = &OS_VxWorks_SymbolDumpState;

/*
** Copy symbol name
*/
strncpy(symRecord.SymbolName, name, sizeof(symRecord.SymbolName) - 1);
symRecord.SymbolName[sizeof(symRecord.SymbolName) - 1] = '\0';

/*
** Check to see if the max length of each symbol name has been reached
*/
if (memchr(name, 0, OS_MAX_SYM_LEN) == NULL)
{
symRecord.SymbolName[sizeof(symRecord.SymbolName) - 2] = '*';
OS_DEBUG("%s(): symbol name too long\n", __func__);
state->StatusCode = OS_ERR_NAME_TOO_LONG;
return false;
}

/*
Expand All @@ -183,12 +192,6 @@ BOOL OS_SymTableIterator_Impl(char *name, SYM_VALUE val, SYM_TYPE type, _Vx_usr_
return false;
}

/*
** Copy symbol name
*/
strncpy(symRecord.SymbolName, name, sizeof(symRecord.SymbolName) - 1);
symRecord.SymbolName[sizeof(symRecord.SymbolName) - 1] = 0;

/*
** Save symbol address
*/
Expand Down

0 comments on commit 2ae7d7d

Please sign in to comment.