dig prints ASCII name instead of failure (#1647829)

This commit is contained in:
Petr Menšík 2019-01-29 19:41:22 +01:00
parent 432a81aeff
commit a699858667
2 changed files with 92 additions and 1 deletions

86
bind-9.11-rh1647829.patch Normal file
View File

@ -0,0 +1,86 @@
From 2eca7f5fa97a24997e4d8f900460ba43ae167e97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Tue, 29 Jan 2019 18:07:44 +0100
Subject: [PATCH] Fallback to ASCII on output IDN conversion error
It is possible dig used ACE encoded name in locale, which does not
support converting it to unicode. Instead of fatal error, fallback to
ACE name on output.
(cherry picked from commit 7f4cb8f9584597fea16de6557124ac8b1bd47440)
Modify idna test to fallback to ACE
Test valid A-label on input would be displayed as A-label on output if
locale does not allow U-label.
(cherry picked from commit 4ce232f8605bdbe0594ebe5a71383c9d4e6f263b)
Emit warning on IDN output failure
Warning is emitted before any dig headers.
(cherry picked from commit 4b410038c531fbb902cd5fb83174eed1f06cb7d7)
---
bin/dig/dighost.c | 15 +++++++++++++--
bin/tests/system/idna/tests.sh | 17 +++++++++++++++++
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c
index bb8702c..d7cfc33 100644
--- a/bin/dig/dighost.c
+++ b/bin/dig/dighost.c
@@ -4860,9 +4860,20 @@ idn_ace_to_locale(const char *from, char *to, size_t tolen) {
*/
res = idn2_to_unicode_8zlz(utf8_src, &tmp_str, 0);
if (res != IDN2_OK) {
- fatal("Cannot represent '%s' in the current locale (%s), "
- "use +noidnout or a different locale",
+ static bool warned = false;
+
+ res = idn2_to_ascii_8z(utf8_src, &tmp_str, 0);
+ if (res != IDN2_OK) {
+ fatal("Cannot represent '%s' "
+ "in the current locale nor ascii (%s), "
+ "use +noidnout or a different locale",
from, idn2_strerror(res));
+ } else if (!warned) {
+ fprintf(stderr, ";; Warning: cannot represent '%s' "
+ "in the current locale",
+ tmp_str);
+ warned = true;
+ }
}
/*
diff --git a/bin/tests/system/idna/tests.sh b/bin/tests/system/idna/tests.sh
index 6637bf6..215a9d5 100644
--- a/bin/tests/system/idna/tests.sh
+++ b/bin/tests/system/idna/tests.sh
@@ -244,6 +244,23 @@ idna_enabled_test() {
idna_test "$text" "+idnin +noidnout" "xn--nxasmq6b.com" "xn--nxasmq6b.com."
idna_test "$text" "+idnin +idnout" "xn--nxasmq6b.com" "βόλοσ.com."
+ # Test of valid A-label in locale that cannot display it
+ #
+ # +noidnout: The string is sent as-is to the server and the returned qname
+ # is displayed in the same form.
+ # +idnout: The string is sent as-is to the server and the returned qname
+ # is displayed as the corresponding A-label.
+ #
+ # The "+[no]idnout" flag has no effect in these cases.
+ text="Checking valid A-label in C locale"
+ label="xn--nxasmq6b.com"
+ LC_ALL=C idna_test "$text" "" "$label" "$label."
+ LC_ALL=C idna_test "$text" "+noidnin +noidnout" "$label" "$label."
+ LC_ALL=C idna_test "$text" "+noidnin +idnout" "$label" "$label."
+ LC_ALL=C idna_test "$text" "+idnin +noidnout" "$label" "$label."
+ LC_ALL=C idna_test "$text" "+idnin +idnout" "$label" "$label."
+ LC_ALL=C idna_test "$text" "+noidnin +idnout" "$label" "$label."
+
# Tests of invalid A-labels
--
2.20.1

View File

@ -54,7 +54,7 @@ Summary: The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) serv
Name: bind
License: MPLv2.0
Version: 9.11.5
Release: 8%{?PATCHVER:.%{PATCHVER}}%{?PREVER:.%{PREVER}}%{?dist}
Release: 9%{?PATCHVER:.%{PATCHVER}}%{?PREVER:.%{PREVER}}%{?dist}
Epoch: 32
Url: http://www.isc.org/products/BIND/
#
@ -133,6 +133,8 @@ Patch162:bind-9.11-unit-dnstap-pkcs11.patch
Patch163:bind-9.11-rh1663318.patch
# https://gitlab.isc.org/isc-projects/bind9/issues/819
Patch164:bind-9.11-rh1666814.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1647829
Patch165:bind-9.11-rh1647829.patch
# SDB patches
Patch11: bind-9.3.2b2-sdbsrc.patch
@ -510,6 +512,7 @@ are used for building ISC DHCP.
%patch162 -p1 -b .dnstap-pkcs11
%patch163 -p1 -b .rh1663318
%patch164 -p1 -b .rh1666814
%patch165 -p1 -b .rh1647829
mkdir lib/dns/tests/testdata/dstrandom
cp -a %{SOURCE50} lib/dns/tests/testdata/dstrandom/random.data
@ -1512,6 +1515,8 @@ fi;
%changelog
* Thu Jan 31 2019 Petr Menšík <pemensik@redhat.com> - 32:9.11.5-9.P1
- dig prints ASCII name instead of failure (#1647829)
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 32:9.11.5-8.P1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild