Fix --hostname option.
This commit is contained in:
parent
d96cb14711
commit
121e4d1510
@ -42,8 +42,8 @@ struct client_config_t {
|
||||
char abort_if_no_lease; /* Abort if no lease */
|
||||
char background_if_no_lease; /* Fork to background if no lease */
|
||||
char *interface; /* The name of the interface to use */
|
||||
unsigned char *clientid; /* Optional client id to use */
|
||||
unsigned char *hostname; /* Optional hostname to use */
|
||||
unsigned char *clientid; /* Optional client id to use (unterminated) */
|
||||
unsigned char *hostname; /* Optional hostname to use (unterminated) */
|
||||
int ifindex; /* Index number of the interface to use */
|
||||
unsigned char arp[6]; /* Our arp address */
|
||||
};
|
||||
|
@ -326,14 +326,13 @@ int main(int argc, char **argv)
|
||||
len = strlen(optarg) > 64 ? 64 : strlen(optarg);
|
||||
if (client_config.hostname)
|
||||
free(client_config.hostname);
|
||||
client_config.hostname = xmalloc(len + 1);
|
||||
client_config.hostname = xmalloc(len + 3);
|
||||
client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
|
||||
client_config.hostname[OPT_LEN] = len;
|
||||
strlcpy((char*)client_config.hostname + OPT_DATA, optarg,
|
||||
len + 1 - (OPT_DATA - OPT_CODE));
|
||||
client_config.hostname[OPT_LEN] = len + 1;
|
||||
memcpy(client_config.hostname + 3, optarg, len);
|
||||
break;
|
||||
case 'i':
|
||||
client_config.interface = optarg;
|
||||
client_config.interface = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
client_config.abort_if_no_lease = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user