From 87b28de0157a6f92e7f96af37c983a2487b9f15b Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Fri, 24 Dec 2010 10:27:24 -0500 Subject: [PATCH] Fix --clientid option. --- ndhc/ndhc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ndhc/ndhc.c b/ndhc/ndhc.c index 067a219..811fe15 100644 --- a/ndhc/ndhc.c +++ b/ndhc/ndhc.c @@ -302,14 +302,13 @@ int main(int argc, char **argv) switch (c) { case 'c': - len = strlen(optarg) > 255 ? 255 : strlen(optarg); + len = strlen(optarg) > 64 ? 64 : strlen(optarg); if (client_config.clientid) free(client_config.clientid); - client_config.clientid = xmalloc(len + 1); + client_config.clientid = xmalloc(len + 3); client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; - client_config.clientid[OPT_LEN] = len; - strlcpy((char *)client_config.clientid + OPT_DATA, optarg, - len + 1 - (OPT_DATA - OPT_CODE)); + client_config.clientid[OPT_LEN] = len + 1; + memcpy(client_config.clientid + 3, optarg, len); break; case 'f': client_config.foreground = 1; @@ -324,7 +323,7 @@ int main(int argc, char **argv) break; case 'h': case 'H': - len = strlen(optarg) > 255 ? 255 : strlen(optarg); + len = strlen(optarg) > 64 ? 64 : strlen(optarg); if (client_config.hostname) free(client_config.hostname); client_config.hostname = xmalloc(len + 1);