]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
dig: setup IDN whenever printing a message
authorEvan Hunt <each@isc.org>
Sat, 12 Sep 2020 20:23:52 +0000 (13:23 -0700)
committerOndřej Surý <ondrej@sury.org>
Sat, 7 Nov 2020 19:49:53 +0000 (20:49 +0100)
because dig now uses the netmgr, printing of response messages
happens in a different thread than setup. the IDN output filtering
procedure, which set using dns_name_settotextfilter(), is stored as
thread-local data, and so if it's set during setup, it won't be
accessible when printing. we now set it immediately before printing,
in the same thread, and clear it immedately afterward.

bin/dig/dig.c
bin/dig/dighost.c
bin/dig/dighost.h

index 3dac5aa28bc7ef9592636d316079843c77435cdf..692ea5ccac9ef833d221f14264fd43bd93903473 100644 (file)
@@ -552,6 +552,8 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
 
        UNUSED(msgbuf);
 
+       dig_idnsetup(query->lookup, true);
+
        styleflags |= DNS_STYLEFLAG_REL_OWNER;
        if (yaml) {
                msg->indent.string = "  ";
@@ -912,6 +914,9 @@ repopulate_buffer:
        if (style != NULL) {
                dns_master_styledestroy(&style, mctx);
        }
+
+       dig_idnsetup(query->lookup, false);
+
        return (result);
 }
 
index c3e428fb0ef655742be16e8026bbfe93726148eb..525bf53dc8dd6605e5ca087e9b791fc7f1e4f734 100644 (file)
@@ -2117,10 +2117,6 @@ setup_lookup(dig_lookup_t *lookup) {
 
 #ifdef HAVE_LIBIDN2
        char idn_origin[MXNAME], idn_textname[MXNAME];
-
-       result = dns_name_settotextfilter(lookup->idnout ? idn_output_filter
-                                                        : NULL);
-       check_result(result, "dns_name_settotextfilter");
 #endif /* HAVE_LIBIDN2 */
 
        INSIST(!free_now);
@@ -4234,10 +4230,6 @@ cancel_all(void) {
  */
 void
 destroy_libs(void) {
-#ifdef HAVE_LIBIDN2
-       isc_result_t result;
-#endif /* HAVE_LIBIDN2 */
-
        if (keep != NULL) {
                isc_nmhandle_detach(&keep);
        }
@@ -4275,11 +4267,6 @@ destroy_libs(void) {
 
        clear_searchlist();
 
-#ifdef HAVE_LIBIDN2
-       result = dns_name_settotextfilter(NULL);
-       check_result(result, "dns_name_settotextfilter");
-#endif /* HAVE_LIBIDN2 */
-
        if (commctx != NULL) {
                debug("freeing commctx");
                isc_mempool_destroy(&commctx);
@@ -4476,3 +4463,17 @@ idn_ace_to_locale(const char *src, char **dst) {
        *dst = local_src;
 }
 #endif /* HAVE_LIBIDN2 */
+
+void
+dig_idnsetup(dig_lookup_t *lookup, bool active) {
+#ifdef HAVE_LIBIDN2
+       isc_result_t result;
+       result = dns_name_settotextfilter(
+               (active && lookup->idnout) ? idn_output_filter : NULL);
+       check_result(result, "dns_name_settotextfilter");
+#else
+       UNUSED(lookup);
+       UNUSED(active);
+       return;
+#endif /* HAVE_LIBIDN2 */
+}
index f9bbaf92d3fe0652e7afc629f9d7366fb753d0cb..2e3278ae06551e98d1d493bdebdd9bc38e315321 100644 (file)
@@ -388,32 +388,38 @@ setup_text_key(void);
  * Routines exported from dig.c for use by dig for iOS
  */
 
-/*%<
+/*%
  * Call once only to set up libraries, parse global
  * parameters and initial command line query parameters
  */
 void
 dig_setup(int argc, char **argv);
 
-/*%<
+/*%
  * Call to supply new parameters for the next lookup
  */
 void
 dig_query_setup(bool, bool, int argc, char **argv);
 
-/*%<
+/*%
  * set the main application event cycle running
  */
 void
 dig_startup(void);
 
-/*%<
+/*%
  * Initiates the next lookup cycle
  */
 void
 dig_query_start(void);
 
-/*%<
+/*%
+ * Activate/deactivate IDN filtering of output.
+ */
+void
+dig_idnsetup(dig_lookup_t *lookup, bool active);
+
+/*%
  * Cleans up the application
  */
 void