diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-03-22 16:45:49 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-03-22 16:45:49 +0000 |
commit | e71f45838174a033dbb648165acba3cdd0c34ca7 (patch) | |
tree | a9fd90b8304b355a319ca817406848dc69dff985 | |
parent | a5dcdb148cb52d09d4186324aef74f432ea6b445 (diff) |
Revert parts of recent changes to pretty_print_domain_search(). Parts
of WIP escaped into the wild and broke parsing of domain-search.
Reported by Greg Steuck and Raf Czlonka. Fix tested by Greg.
-rw-r--r-- | sbin/dhclient/dhclient.c | 6 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 3 | ||||
-rw-r--r-- | sbin/dhclient/options.c | 21 |
3 files changed, 12 insertions, 18 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 0fd9a2a62a4..e4fc18d214d 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.629 2019/03/20 20:10:00 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.630 2019/03/22 16:45:48 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -1921,8 +1921,8 @@ lease_as_proposal(struct client_lease *lease) if (lease->options[DHO_DOMAIN_SEARCH].len != 0) { opt = &lease->options[DHO_DOMAIN_SEARCH]; - pretty = pretty_print_option(DHO_DOMAIN_SEARCH, opt, 0); - if (strlen(pretty) > 0 && strlen(pretty) < + pretty = pretty_print_domain_search(opt->data, opt->len); + if (pretty != NULL && strlen(pretty) > 0 && strlen(pretty) < sizeof(proposal->rtsearch)) { proposal->rtsearch_len = strlen(pretty); memcpy(proposal->rtsearch, pretty, diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 766c552be33..a765409d961 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.275 2019/03/20 20:10:00 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.276 2019/03/22 16:45:48 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -160,6 +160,7 @@ struct option_data *unpack_options(struct dhcp_packet *); char *pretty_print_option(unsigned int, struct option_data *, int); char *pretty_print_string(unsigned char *, size_t, int); +char *pretty_print_domain_search(unsigned char *, size_t); char *code_to_name(int); char *code_to_format(int); int code_to_action(int, int); diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c index 9cb60e8d1d4..38beeb18834 100644 --- a/sbin/dhclient/options.c +++ b/sbin/dhclient/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.116 2019/03/21 00:45:46 krw Exp $ */ +/* $OpenBSD: options.c,v 1.117 2019/03/22 16:45:48 krw Exp $ */ /* DHCP options parsing and reassembly. */ @@ -64,8 +64,6 @@ int parse_option_buffer(struct option_data *, unsigned char *, int); void pretty_print_classless_routes(unsigned char *, size_t, unsigned char *, size_t); -void pretty_print_domain_search(unsigned char *, size_t, unsigned char *, - size_t); int expand_search_domain_name(unsigned char *, size_t, int *, unsigned char *); /* @@ -739,11 +737,10 @@ expand_search_domain_name(unsigned char *src, size_t srclen, int *offset, * Must special case DHO_DOMAIN_SEARCH because it is encoded as described * in RFC 1035 section 4.1.4. */ -void -pretty_print_domain_search(unsigned char *src, size_t srclen, - unsigned char *buf, size_t buflen) +char * +pretty_print_domain_search(unsigned char *src, size_t srclen) { - char domain_search[DHCP_DOMAIN_SEARCH_LEN]; + static char domain_search[DHCP_DOMAIN_SEARCH_LEN]; unsigned char *cursor; unsigned int offset; int len, expanded_len, domains; @@ -763,15 +760,14 @@ pretty_print_domain_search(unsigned char *src, size_t srclen, len = expand_search_domain_name(src, srclen, &offset, domain_search); if (len == -1) - return; + return NULL; domains++; expanded_len += len; if (domains > DHCP_DOMAIN_SEARCH_CNT) - return; + return NULL; } - if (strlcpy(buf, domain_search, buflen) >= buflen) - memset(buf, 0, buflen); + return domain_search; } /* @@ -816,9 +812,6 @@ pretty_print_option(unsigned int code, struct option_data *option, case DHO_CLASSLESS_MS_STATIC_ROUTES: pretty_print_classless_routes(dp, len, optbuf, sizeof(optbuf)); goto done; - case DHO_DOMAIN_SEARCH: - pretty_print_domain_search(dp, len, optbuf, sizeof(optbuf)); - goto done; default: break; } |