diff options
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/clparse.c | 24 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 4 | ||||
-rw-r--r-- | sbin/dhclient/parse.c | 11 |
3 files changed, 19 insertions, 20 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 9d6c38e6a96..86576b70da7 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.189 2019/07/20 17:14:15 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.190 2019/07/21 15:47:02 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -284,7 +284,7 @@ parse_conf_decl(FILE *cfile, char *name) config->default_actions[i] = ACTION_DEFAULT; break; case TOK_FILENAME: - if (parse_string(cfile, NULL, &val) == 0) + if (parse_string(cfile, &val) == 0) return; free(config->filename); config->filename = val; @@ -367,7 +367,7 @@ parse_conf_decl(FILE *cfile, char *name) return; break; case TOK_SERVER_NAME: - if (parse_string(cfile, NULL, &val) == 0) + if (parse_string(cfile, &val) == 0) return; free(config->server_name); config->server_name = val; @@ -466,7 +466,7 @@ parse_domain_list(FILE *cfile, int *len, char **dp) count = 0; do { - if (parse_string(cfile, NULL, &domain) == 0) + if (parse_string(cfile, &domain) == 0) return 0; count++; @@ -696,7 +696,7 @@ parse_lease_decl(FILE *cfile, struct client_lease *lease) skip_to_semi(cfile); return; case TOK_FILENAME: - if (parse_string(cfile, NULL, &val) == 0) + if (parse_string(cfile, &val) == 0) return; free(lease->filename); lease->filename = val; @@ -723,14 +723,15 @@ parse_lease_decl(FILE *cfile, struct client_lease *lease) skip_to_semi(cfile); return; case TOK_SERVER_NAME: - if (parse_string(cfile, NULL, &val) == 0) + if (parse_string(cfile, &val) == 0) return; free(lease->server_name); lease->server_name = val; break; case TOK_SSID: - if (parse_string(cfile, &len, &val) == 0) + if (parse_string(cfile, &val) == 0) return; + len = strlen(val); if (len > sizeof(lease->ssid)) { free(val); parse_warn("ssid > 32 bytes"); @@ -797,18 +798,19 @@ parse_option(FILE *cfile, int *code, struct option_data *options) switch (*fmt) { case 'X': if (peek_token(NULL, cfile) == TOK_STRING) { - if (parse_string(cfile, &len, - (char **)&dp) == 0) + if (parse_string(cfile, (char **)&dp) + == 0) return 0; + len = strlen(dp); } else if (parse_hex_octets(cfile, &len, &dp) == 0) return 0; freedp = 1; break; case 't': /* Text string. */ - if (parse_string(cfile, &len, (char **)&dp) - == 0) + if (parse_string(cfile, (char **)&dp) == 0) return 0; + len = strlen(dp); freedp = 1; break; case 'I': /* IP address. */ diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 8a5d55c74b3..7ce7a100c3b 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.279 2019/07/19 20:50:22 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.280 2019/07/21 15:47:02 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -179,7 +179,7 @@ int peek_token(char **, FILE *); /* parse.c */ void skip_to_semi(FILE *); int parse_semi(FILE *); -int parse_string(FILE *, unsigned int *, char **); +int parse_string(FILE *, char **); int parse_ip_addr(FILE *, struct in_addr *); int parse_cidr(FILE *, unsigned char *); int parse_number(FILE *, unsigned char *, char); diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c index 16bb594bb92..43e79c835ea 100644 --- a/sbin/dhclient/parse.c +++ b/sbin/dhclient/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.80 2019/03/19 23:57:30 krw Exp $ */ +/* $OpenBSD: parse.c,v 1.81 2019/07/21 15:47:02 krw Exp $ */ /* Common parser code for dhcpd and dhclient. */ @@ -120,7 +120,7 @@ parse_semi(FILE *cfile) } int -parse_string(FILE *cfile, unsigned int *len, char **string) +parse_string(FILE *cfile, char **string) { static char unvisbuf[1500]; char *val; @@ -130,12 +130,9 @@ parse_string(FILE *cfile, unsigned int *len, char **string) if (token == TOK_STRING) { i = strnunvis(unvisbuf, val, sizeof(unvisbuf)); if (i >= 0) { - *string = malloc(i+1); + *string = strdup(unvisbuf); if (*string == NULL) - fatal("unvis string %s", val); - memcpy(*string, unvisbuf, i+1); /* Copy the NUL. */ - if (len != NULL) - *len = i; + fatal("strdup(unvisbuf)"); return 1; } } |