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:
parent
aba37c6478
commit
d6eec465f4
@ -177,6 +177,7 @@ int hostw_service_command ( hostw_socket_type * hostw_socket)
|
|||||||
*/
|
*/
|
||||||
int len = sizeof(msg[0]) + 1;
|
int len = sizeof(msg[0]) + 1;
|
||||||
|
|
||||||
|
memset(msg, 0, 2*sizeof(msg[0]));
|
||||||
socklen_t addrlen = (socklen_t) sizeof(hostw_socket->status_addr);
|
socklen_t addrlen = (socklen_t) sizeof(hostw_socket->status_addr);
|
||||||
len = recvfrom(hostw_socket->status_sock,
|
len = recvfrom(hostw_socket->status_sock,
|
||||||
(char*)&msg,
|
(char*)&msg,
|
||||||
|
@ -246,6 +246,8 @@ int hwmon_service_inbox ( void )
|
|||||||
return (FAIL_UNKNOWN_HOSTNAME);
|
return (FAIL_UNKNOWN_HOSTNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* add string terminator for protection */
|
||||||
|
msg.buf[BUF_SIZE-1] = '\0';
|
||||||
rc = hwmonJson_load_inv ( &msg.buf[0], inv );
|
rc = hwmonJson_load_inv ( &msg.buf[0], inv );
|
||||||
if ( rc )
|
if ( rc )
|
||||||
{
|
{
|
||||||
|
@ -144,6 +144,7 @@ int mtc_service_inbox ( nodeLinkClass * obj_ptr,
|
|||||||
{
|
{
|
||||||
bytes = sock_ptr->mtc_agent_rx_socket->read((char*)&msg, sizeof(msg));
|
bytes = sock_ptr->mtc_agent_rx_socket->read((char*)&msg, sizeof(msg));
|
||||||
}
|
}
|
||||||
|
msg.buf[BUF_SIZE-1] = '\0';
|
||||||
|
|
||||||
if ( bytes <= 0 )
|
if ( bytes <= 0 )
|
||||||
{
|
{
|
||||||
|
@ -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);
|
bytes = recvfrom( rmon_sock.rmon_tx_sock, buf, RMON_MAX_LEN, 0, (struct sockaddr *)&rmon_sock.rmon_tx_addr, &len);
|
||||||
if ( bytes > 0 )
|
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
|
sscanf ( buf, "%99s %99s %u", str, registered_not, &port ); //RMON_MAX_LEN is defined as 100
|
||||||
strcpy( active_buf, buf );
|
strcpy( active_buf, buf );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user