summaryrefslogtreecommitdiffstats
path: root/src/vnet/dhcp
diff options
context:
space:
mode:
authorJon Loeliger <jdl@netgate.com>2017-04-27 21:20:51 -0500
committerJon Loeliger <jdl@netgate.com>2017-04-28 08:59:59 -0500
commit69186d930ff43b127269abc568bdc656b1e635ad (patch)
tree47b99d9fefc839ac85c916a0967cba47b64d0521 /src/vnet/dhcp
parentc855b73f785b3c4c1756927ad542de13ba193b6f (diff)
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 <jdl@netgate.com>
Diffstat (limited to 'src/vnet/dhcp')
-rw-r--r--src/vnet/dhcp/dhcp_api.c6
1 files changed, 4 insertions, 2 deletions
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);