diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2020-01-09 14:19:50 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2020-01-09 14:19:50 +0000 |
commit | b1c3712e7543fa0abbc95347af9b4346e30847ae (patch) | |
tree | 45e46a85cbea9d90d4b8bd3749b4103010280206 /usr.sbin/bind/bin/dig | |
parent | f8383418ca1598299c555b342b4b5e02f54268e8 (diff) |
unifdef WITH_IDN; prodding deraadt@
Diffstat (limited to 'usr.sbin/bind/bin/dig')
-rw-r--r-- | usr.sbin/bind/bin/dig/dig.c | 6 | ||||
-rw-r--r-- | usr.sbin/bind/bin/dig/dighost.c | 194 | ||||
-rw-r--r-- | usr.sbin/bind/bin/dig/host.c | 23 | ||||
-rw-r--r-- | usr.sbin/bind/bin/dig/include/dig/dig.h | 3 |
4 files changed, 2 insertions, 224 deletions
diff --git a/usr.sbin/bind/bin/dig/dig.c b/usr.sbin/bind/bin/dig/dig.c index e4dfac8eb89..847087b84c7 100644 --- a/usr.sbin/bind/bin/dig/dig.c +++ b/usr.sbin/bind/bin/dig/dig.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dig.c,v 1.33 2020/01/09 14:18:29 florian Exp $ */ +/* $Id: dig.c,v 1.34 2020/01/09 14:19:49 florian Exp $ */ /*! \file */ @@ -982,11 +982,7 @@ plus_option(const char *option, isc_boolean_t is_batchfile, break; case 'n': FULLCHECK("idnout"); -#ifndef WITH_IDN fprintf(stderr, ";; IDN support not enabled\n"); -#else - lookup->idnout = state; -#endif break; default: goto invalid_option; diff --git a/usr.sbin/bind/bin/dig/dighost.c b/usr.sbin/bind/bin/dig/dighost.c index 50143d1f8f9..9532869d9c4 100644 --- a/usr.sbin/bind/bin/dig/dighost.c +++ b/usr.sbin/bind/bin/dig/dighost.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.26 2020/01/09 14:18:29 florian Exp $ */ +/* $Id: dighost.c,v 1.27 2020/01/09 14:19:49 florian Exp $ */ /*! \file * \note @@ -36,13 +36,6 @@ #include <locale.h> #endif -#ifdef WITH_IDN -#include <idn/result.h> -#include <idn/log.h> -#include <idn/resconf.h> -#include <idn/api.h> -#endif - #include <dns/byaddr.h> #ifdef DIG_SIGCHASE #include <dns/callbacks.h> @@ -147,19 +140,6 @@ int lookup_counter = 0; static char sitvalue[256]; -#ifdef WITH_IDN -static void initialize_idn(void); -static isc_result_t output_filter(isc_buffer_t *buffer, - unsigned int used_org, - isc_boolean_t absolute); -static idn_result_t append_textname(char *name, const char *origin, - size_t namesize); -static void idn_check_result(idn_result_t r, const char *msg); - -#define MAXDLEN 256 -int idnoptions = 0; -#endif - isc_socket_t *keep = NULL; isc_sockaddr_t keepaddr; @@ -853,11 +833,7 @@ make_empty_lookup(void) { looknew->opcode = dns_opcode_query; looknew->expire = ISC_FALSE; looknew->nsid = ISC_FALSE; -#ifdef WITH_IDN - looknew->idnout = ISC_TRUE; -#else looknew->idnout = ISC_FALSE; -#endif looknew->sit = ISC_FALSE; #ifdef DIG_SIGCHASE looknew->sigchase = ISC_FALSE; @@ -1511,10 +1487,6 @@ setup_system(isc_boolean_t ipv4only, isc_boolean_t ipv6only) { copy_server_list(lwconf, &server_list); } -#ifdef WITH_IDN - initialize_idn(); -#endif - if (keyfile[0] != 0) setup_file_key(); else if (keysecret[0] != 0) @@ -2336,16 +2308,6 @@ setup_lookup(dig_lookup_t *lookup) { char store[MXNAME]; char ecsbuf[20]; char sitbuf[256]; -#ifdef WITH_IDN - idn_result_t mr; - char utf8_textname[MXNAME], utf8_origin[MXNAME], idn_textname[MXNAME]; -#endif - -#ifdef WITH_IDN - result = dns_name_settotextfilter(lookup->idnout ? - output_filter : NULL); - check_result(result, "dns_name_settotextfilter"); -#endif REQUIRE(lookup != NULL); INSIST(!free_now); @@ -2374,17 +2336,6 @@ setup_lookup(dig_lookup_t *lookup) { isc_buffer_init(&lookup->onamebuf, lookup->oname_space, sizeof(lookup->oname_space)); -#ifdef WITH_IDN - /* - * We cannot convert `textname' and `origin' separately. - * `textname' doesn't contain TLD, but local mapping needs - * TLD. - */ - mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, lookup->textname, - utf8_textname, sizeof(utf8_textname)); - idn_check_result(mr, "convert textname to UTF-8"); -#endif - /* * If the name has too many dots, force the origin to be NULL * (which produces an absolute lookup). Otherwise, take the origin @@ -2393,16 +2344,6 @@ setup_lookup(dig_lookup_t *lookup) { * is TRUE or we got a domain line in the resolv.conf file. */ if (lookup->new_search) { -#ifdef WITH_IDN - if ((count_dots(utf8_textname) >= ndots) || !usesearch) { - lookup->origin = NULL; /* Force abs lookup */ - lookup->done_as_is = ISC_TRUE; - lookup->need_search = usesearch; - } else if (lookup->origin == NULL && usesearch) { - lookup->origin = ISC_LIST_HEAD(search_list); - lookup->need_search = ISC_FALSE; - } -#else if ((count_dots(lookup->textname) >= ndots) || !usesearch) { lookup->origin = NULL; /* Force abs lookup */ lookup->done_as_is = ISC_TRUE; @@ -2411,24 +2352,8 @@ setup_lookup(dig_lookup_t *lookup) { lookup->origin = ISC_LIST_HEAD(search_list); lookup->need_search = ISC_FALSE; } -#endif } -#ifdef WITH_IDN - if (lookup->origin != NULL) { - mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, - lookup->origin->origin, utf8_origin, - sizeof(utf8_origin)); - idn_check_result(mr, "convert origin to UTF-8"); - mr = append_textname(utf8_textname, utf8_origin, - sizeof(utf8_textname)); - idn_check_result(mr, "append origin to textname"); - } - mr = idn_encodename(idnoptions | IDN_LOCALMAP | IDN_NAMEPREP | - IDN_IDNCONV | IDN_LENCHECK, utf8_textname, - idn_textname, sizeof(idn_textname)); - idn_check_result(mr, "convert UTF-8 textname to IDN encoding"); -#else if (lookup->origin != NULL) { debug("trying origin %s", lookup->origin->origin); result = dns_message_gettempname(lookup->sendmsg, @@ -2485,27 +2410,17 @@ setup_lookup(dig_lookup_t *lookup) { } dns_message_puttempname(lookup->sendmsg, &lookup->oname); } else -#endif { debug("using root origin"); if (lookup->trace && lookup->trace_root) dns_name_clone(dns_rootname, lookup->name); else { -#ifdef WITH_IDN - len = (unsigned int) strlen(idn_textname); - isc_buffer_init(&b, idn_textname, len); - isc_buffer_add(&b, len); - result = dns_name_fromtext(lookup->name, &b, - dns_rootname, 0, - &lookup->namebuf); -#else len = (unsigned int) strlen(lookup->textname); isc_buffer_init(&b, lookup->textname, len); isc_buffer_add(&b, len); result = dns_name_fromtext(lookup->name, &b, dns_rootname, 0, &lookup->namebuf); -#endif } if (result != ISC_R_SUCCESS) { dns_message_puttempname(lookup->sendmsg, @@ -4420,9 +4335,6 @@ destroy_libs(void) { void * ptr; dig_message_t *chase_msg; #endif -#ifdef WITH_IDN - isc_result_t result; -#endif if (keep != NULL) isc_socket_detach(&keep); @@ -4456,10 +4368,6 @@ destroy_libs(void) { clear_searchlist(); -#ifdef WITH_IDN - result = dns_name_settotextfilter(NULL); - check_result(result, "dns_name_settotextfilter"); -#endif dns_name_destroy(); if (commctx != NULL) { @@ -4540,106 +4448,6 @@ destroy_libs(void) { isc_mem_destroy(&mctx); } -#ifdef WITH_IDN -static void -initialize_idn(void) { - idn_result_t r; - isc_result_t result; - -#ifdef HAVE_SETLOCALE - /* Set locale */ - (void)setlocale(LC_ALL, ""); -#endif - /* Create configuration context. */ - r = idn_nameinit(1); - if (r != idn_success) - fatal("idn api initialization failed: %s", - idn_result_tostring(r)); - - /* Set domain name -> text post-conversion filter. */ - result = dns_name_settotextfilter(output_filter); - check_result(result, "dns_name_settotextfilter"); -} - -static isc_result_t -output_filter(isc_buffer_t *buffer, unsigned int used_org, - isc_boolean_t absolute) -{ - char tmp1[MAXDLEN], tmp2[MAXDLEN]; - size_t fromlen, tolen; - isc_boolean_t end_with_dot; - - /* - * Copy contents of 'buffer' to 'tmp1', supply trailing dot - * if 'absolute' is true, and terminate with NUL. - */ - fromlen = isc_buffer_usedlength(buffer) - used_org; - if (fromlen >= MAXDLEN) - return (ISC_R_SUCCESS); - memmove(tmp1, (char *)isc_buffer_base(buffer) + used_org, fromlen); - end_with_dot = (tmp1[fromlen - 1] == '.') ? ISC_TRUE : ISC_FALSE; - if (absolute && !end_with_dot) { - fromlen++; - if (fromlen >= MAXDLEN) - return (ISC_R_SUCCESS); - tmp1[fromlen - 1] = '.'; - } - tmp1[fromlen] = '\0'; - - /* - * Convert contents of 'tmp1' to local encoding. - */ - if (idn_decodename(IDN_DECODE_APP, tmp1, tmp2, MAXDLEN) != idn_success) - return (ISC_R_SUCCESS); - strlcpy(tmp1, tmp2, MAXDLEN); - - /* - * Copy the converted contents in 'tmp1' back to 'buffer'. - * If we have appended trailing dot, remove it. - */ - tolen = strlen(tmp1); - if (absolute && !end_with_dot && tmp1[tolen - 1] == '.') - tolen--; - - if (isc_buffer_length(buffer) < used_org + tolen) - return (ISC_R_NOSPACE); - - isc_buffer_subtract(buffer, isc_buffer_usedlength(buffer) - used_org); - memmove(isc_buffer_used(buffer), tmp1, tolen); - isc_buffer_add(buffer, (unsigned int)tolen); - - return (ISC_R_SUCCESS); -} - -static idn_result_t -append_textname(char *name, const char *origin, size_t namesize) { - size_t namelen = strlen(name); - size_t originlen = strlen(origin); - - /* Already absolute? */ - if (namelen > 0 && name[namelen - 1] == '.') - return (idn_success); - - /* Append dot and origin */ - - if (namelen + 1 + originlen >= namesize) - return (idn_buffer_overflow); - - if (*origin != '.') - name[namelen++] = '.'; - (void)strlcpy(name + namelen, origin, namesize - namelen); - return (idn_success); -} - -static void -idn_check_result(idn_result_t r, const char *msg) { - if (r != idn_success) { - exitcode = 1; - fatal("%s: %s", msg, idn_result_tostring(r)); - } -} -#endif /* WITH_IDN */ - #ifdef DIG_SIGCHASE void print_type(dns_rdatatype_t type) diff --git a/usr.sbin/bind/bin/dig/host.c b/usr.sbin/bind/bin/dig/host.c index f2fa997daa0..98332b92b10 100644 --- a/usr.sbin/bind/bin/dig/host.c +++ b/usr.sbin/bind/bin/dig/host.c @@ -25,13 +25,6 @@ #include <locale.h> #endif -#ifdef WITH_IDN -#include <idn/result.h> -#include <idn/log.h> -#include <idn/resconf.h> -#include <idn/api.h> -#endif - #include <isc/app.h> #include <isc/commandline.h> #include <isc/netaddr.h> @@ -709,9 +702,6 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { lookup->rdtype != dns_rdatatype_axfr) lookup->rdtype = rdtype; lookup->rdtypeset = ISC_TRUE; -#ifdef WITH_IDN - idnoptions = 0; -#endif if (rdtype == dns_rdatatype_axfr) { /* -l -t any -v */ list_type = dns_rdatatype_any; @@ -721,13 +711,6 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { lookup->ixfr_serial = serial; lookup->tcp_mode = ISC_TRUE; list_type = rdtype; -#ifdef WITH_IDN - } else if (rdtype == dns_rdatatype_a || - rdtype == dns_rdatatype_aaaa || - rdtype == dns_rdatatype_mx) { - idnoptions = IDN_ASCCHECK; - list_type = rdtype; -#endif } else list_type = rdtype; list_addresses = ISC_FALSE; @@ -753,9 +736,6 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { if (!lookup->rdtypeset || lookup->rdtype != dns_rdatatype_axfr) lookup->rdtype = dns_rdatatype_any; -#ifdef WITH_IDN - idnoptions = 0; -#endif list_type = dns_rdatatype_any; list_addresses = ISC_FALSE; lookup->rdtypeset = ISC_TRUE; @@ -862,9 +842,6 @@ main(int argc, char **argv) { ISC_LIST_INIT(search_list); fatalexit = 1; -#ifdef WITH_IDN - idnoptions = IDN_ASCCHECK; -#endif /* setup dighost callbacks */ #ifdef DIG_SIGCHASE diff --git a/usr.sbin/bind/bin/dig/include/dig/dig.h b/usr.sbin/bind/bin/dig/include/dig/dig.h index 0e93a989b40..57923da88d5 100644 --- a/usr.sbin/bind/bin/dig/include/dig/dig.h +++ b/usr.sbin/bind/bin/dig/include/dig/dig.h @@ -293,9 +293,6 @@ extern isc_boolean_t keep_open; extern char *progname; extern int tries; extern int fatalexit; -#ifdef WITH_IDN -extern int idnoptions; -#endif /* * Routines in dighost.c. |