Fix --clientid option.
This commit is contained in:
parent
c0b699ba88
commit
87b28de015
11
ndhc/ndhc.c
11
ndhc/ndhc.c
@ -302,14 +302,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
len = strlen(optarg) > 64 ? 64 : strlen(optarg);
|
||||||
if (client_config.clientid)
|
if (client_config.clientid)
|
||||||
free(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_CODE] = DHCP_CLIENT_ID;
|
||||||
client_config.clientid[OPT_LEN] = len;
|
client_config.clientid[OPT_LEN] = len + 1;
|
||||||
strlcpy((char *)client_config.clientid + OPT_DATA, optarg,
|
memcpy(client_config.clientid + 3, optarg, len);
|
||||||
len + 1 - (OPT_DATA - OPT_CODE));
|
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
client_config.foreground = 1;
|
client_config.foreground = 1;
|
||||||
@ -324,7 +323,7 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case 'H':
|
case 'H':
|
||||||
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
len = strlen(optarg) > 64 ? 64 : strlen(optarg);
|
||||||
if (client_config.hostname)
|
if (client_config.hostname)
|
||||||
free(client_config.hostname);
|
free(client_config.hostname);
|
||||||
client_config.hostname = xmalloc(len + 1);
|
client_config.hostname = xmalloc(len + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user