diff --git a/mtce/src/hwmon/hwmonSensor.cpp b/mtce/src/hwmon/hwmonSensor.cpp index 5f4a2e50..475c7cd5 100644 --- a/mtce/src/hwmon/hwmonSensor.cpp +++ b/mtce/src/hwmon/hwmonSensor.cpp @@ -20,7 +20,7 @@ #include "hwmonGroup.h" /* for ... bmc_get_grouptype */ #include "hwmonAlarm.h" /* for ... hwmonAlarm */ -#define DELIMITER ((const char)',') +#define DELIMITER ((char)',') /**************************************************************************** * diff --git a/mtce/src/lmon/lmonUtil.cpp b/mtce/src/lmon/lmonUtil.cpp index eb0a798e..d0225e8d 100644 --- a/mtce/src/lmon/lmonUtil.cpp +++ b/mtce/src/lmon/lmonUtil.cpp @@ -332,7 +332,7 @@ int lmon_interfaces_init ( interface_ctrl_type * ptr, string physical_interface string line; while ( getline( finTwo, line ) ) { - strncpy(line_buf, line.c_str(), MAX_CHARS_ON_LINE); + snprintf(line_buf, sizeof(line_buf), "%s", line.c_str()); // the slave interfaces are listed as enXYYY enXYYY... // starting with the primary. Read all other slaves diff --git a/mtce/src/public/amon.c b/mtce/src/public/amon.c index b9146a2d..8c9d0c60 100644 --- a/mtce/src/public/amon.c +++ b/mtce/src/public/amon.c @@ -237,8 +237,9 @@ int active_monitor_dispatch ( void ) char str[AMON_MAX_LEN] ; unsigned int magic = 0 ; int seq ; + int ret ; - memset (str, 0, AMON_MAX_LEN ); + memset ( str, 0, sizeof(str) ); sscanf ( amon.rx_buf, "%s %8x %d", str, &magic, &seq ); /* Fault Insertion Controls */ @@ -256,8 +257,12 @@ int active_monitor_dispatch ( void ) magic = magic ^ -1 ; } - memset ( amon.tx_buf, 0 , AMON_MAX_LEN ); - sprintf( amon.tx_buf, "%s %8x %d%c", str, magic, seq, '\0' ); + memset ( amon.tx_buf, 0, sizeof(amon.tx_buf) ); + ret = snprintf( amon.tx_buf, sizeof(amon.tx_buf), "%s %8x %d", str, magic, seq ); + if ( ret >= (int)sizeof(amon.tx_buf) ) + { + syslog ( LOG_ERR, "amon.tx_buf is truncated\n"); + } if ( strcmp ( str, amon.name ) ) {