Add explicate string terminator for protection

Verified with Multi-node and duplex deploy and log checking

Closes-Bug:1794937

Change-Id: I3af74efbf66fe71e4920f6cfd7af2b2ef4cb68b6
Signed-off-by: Martin, Chen <haochuan.z.chen@intel.com>
This commit is contained in:
haochuan 2018-10-30 14:31:20 +08:00 committed by Martin, Chen
parent aba37c6478
commit d6eec465f4
4 changed files with 5 additions and 0 deletions

View File

@ -177,6 +177,7 @@ int hostw_service_command ( hostw_socket_type * hostw_socket)
*/
int len = sizeof(msg[0]) + 1;
memset(msg, 0, 2*sizeof(msg[0]));
socklen_t addrlen = (socklen_t) sizeof(hostw_socket->status_addr);
len = recvfrom(hostw_socket->status_sock,
(char*)&msg,

View File

@ -246,6 +246,8 @@ int hwmon_service_inbox ( void )
return (FAIL_UNKNOWN_HOSTNAME);
}
/* add string terminator for protection */
msg.buf[BUF_SIZE-1] = '\0';
rc = hwmonJson_load_inv ( &msg.buf[0], inv );
if ( rc )
{

View File

@ -144,6 +144,7 @@ int mtc_service_inbox ( nodeLinkClass * obj_ptr,
{
bytes = sock_ptr->mtc_agent_rx_socket->read((char*)&msg, sizeof(msg));
}
msg.buf[BUF_SIZE-1] = '\0';
if ( bytes <= 0 )
{

View File

@ -525,6 +525,7 @@ int rmon_service_inbox ( int clients )
bytes = recvfrom( rmon_sock.rmon_tx_sock, buf, RMON_MAX_LEN, 0, (struct sockaddr *)&rmon_sock.rmon_tx_addr, &len);
if ( bytes > 0 )
{
buf[RMON_MAX_LEN-1] = '\0';
sscanf ( buf, "%99s %99s %u", str, registered_not, &port ); //RMON_MAX_LEN is defined as 100
strcpy( active_buf, buf );