From 69186d930ff43b127269abc568bdc656b1e635ad Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Thu, 27 Apr 2017 21:20:51 -0500 Subject: Fix hostname fencepost error in dhcp_compl_event_callback. Hostnames are limited to 63 characters and a NUL terminator. Change-Id: Ie1724d83675cca5e8cdfcd99d8e56e530a044d5d Signed-off-by: Jon Loeliger --- src/vnet/dhcp/dhcp_api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/vnet/dhcp/dhcp_api.c b/src/vnet/dhcp/dhcp_api.c index e9c757e85b6..2c0dd77df28 100644 --- a/src/vnet/dhcp/dhcp_api.c +++ b/src/vnet/dhcp/dhcp_api.c @@ -192,6 +192,7 @@ dhcp_compl_event_callback (u32 client_index, u32 pid, u8 * hostname, { unix_shared_memory_queue_t *q; vl_api_dhcp_compl_event_t *mp; + u32 len; q = vl_api_client_index_to_input_queue (client_index); if (!q) @@ -201,8 +202,9 @@ dhcp_compl_event_callback (u32 client_index, u32 pid, u8 * hostname, mp->client_index = client_index; mp->pid = pid; mp->is_ipv6 = is_ipv6; - clib_memcpy (&mp->hostname, hostname, vec_len (hostname)); - mp->hostname[vec_len (hostname) + 1] = '\n'; + len = (vec_len (hostname) < 63) ? vec_len (hostname) : 63; + clib_memcpy (&mp->hostname, hostname, len); + mp->hostname[len] = 0; clib_memcpy (&mp->host_address[0], host_address, 16); clib_memcpy (&mp->router_address[0], router_address, 16); -- cgit 1.2.3-korg