2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 10:10:06 +00:00

dig: setup IDN whenever printing a message

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.
This commit is contained in:
Evan Hunt 2020-09-12 13:23:52 -07:00 committed by Ondřej Surý
parent cde27d2d2b
commit e12dc1faa2
3 changed files with 30 additions and 18 deletions

View 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);
}

View 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 */
}

View 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