bind 9.8.1
[git/cygwin-packages/bind.git] / 9.7.2-libidn.patch
1 Fedora patches:
2 bind-9.5-libidn.patch
3 bind-9.5-libidn2.patch
4 bind95-rh461409.patch
5 bind-9.5-libidn3.patch
6
7 --- origsrc/bind-9.7.2-P3/bin/dig/Makefile.in 2010-12-24 00:18:37.679834200 -0600
8 +++ src/bind-9.7.2-P3/bin/dig/Makefile.in 2010-12-24 00:16:51.000000000 -0600
9 @@ -46,10 +46,10 @@ DEPLIBS = ${DNSDEPLIBS} ${BIND9DEPLIBS}
10 ${LWRESDEPLIBS}
11
12 LIBS = ${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} ${ISCCFGLIBS} \
13 - ${ISCLIBS} @IDNLIBS@ @LIBS@
14 + ${ISCLIBS} @IDNLIBS@ @LIBS@ -lidn
15
16 NOSYMLIBS = ${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} ${ISCCFGLIBS} \
17 - ${ISCNOSYMLIBS} @IDNLIBS@ @LIBS@
18 + ${ISCNOSYMLIBS} @IDNLIBS@ @LIBS@ -lidn
19
20 SUBDIRS =
21
22 @@ -67,6 +67,8 @@ HTMLPAGES = dig.html host.html nslookup.
23
24 MANOBJS = ${MANPAGES} ${HTMLPAGES}
25
26 +EXT_CFLAGS = -DWITH_LIBIDN
27 +
28 @BIND9_MAKE_RULES@
29
30 dig@EXEEXT@: dig.@O@ dighost.@O@ ${UOBJS} ${DEPLIBS}
31 --- origsrc/bind-9.7.2-P3/bin/dig/dighost.c 2010-12-24 00:18:37.679834200 -0600
32 +++ src/bind-9.7.2-P3/bin/dig/dighost.c 2010-12-24 00:16:52.000000000 -0600
33 @@ -44,6 +44,11 @@
34 #include <idn/api.h>
35 #endif
36
37 +#ifdef WITH_LIBIDN
38 +#include <stringprep.h>
39 +#include <idna.h>
40 +#endif
41 +
42 #include <dns/byaddr.h>
43 #ifdef DIG_SIGCHASE
44 #include <dns/dnssec.h>
45 @@ -153,6 +158,14 @@ static void idn_check_result(idn_result
46 int idnoptions = 0;
47 #endif
48
49 +#ifdef WITH_LIBIDN
50 +static isc_result_t libidn_locale_to_utf8 (const char* from, char *to);
51 +static isc_result_t libidn_utf8_to_ascii (const char* from, char *to);
52 +static isc_result_t output_filter (isc_buffer_t *buffer,
53 + unsigned int used_org,
54 + isc_boolean_t absolute);
55 +#endif
56 +
57 /*%
58 * Exit Codes:
59 *
60 @@ -1193,6 +1206,9 @@ setup_system(void) {
61 dig_searchlist_t *domain = NULL;
62 lwres_result_t lwresult;
63 unsigned int lwresflags;
64 +#ifdef WITH_LIBIDN
65 + isc_result_t result;
66 +#endif
67
68 debug("setup_system()");
69
70 @@ -1251,8 +1267,15 @@ setup_system(void) {
71
72 #ifdef WITH_IDN
73 initialize_idn();
74 +
75 +#endif
76 +#ifdef WITH_LIBIDN
77 + result = dns_name_settotextfilter(output_filter);
78 + check_result(result, "dns_name_settotextfilter");
79 +#ifdef HAVE_SETLOCALE
80 + setlocale (LC_ALL, "");
81 +#endif
82 #endif
83 -
84 if (keyfile[0] != 0)
85 setup_file_key();
86 else if (keysecret[0] != 0)
87 @@ -1958,12 +1981,14 @@ setup_lookup(dig_lookup_t *lookup) {
88 idn_result_t mr;
89 char utf8_textname[MXNAME], utf8_origin[MXNAME], idn_textname[MXNAME];
90 #endif
91 +#ifdef WITH_LIBIDN
92 + char utf8_str[MXNAME], utf8_name[MXNAME], ascii_name[MXNAME];
93 +#endif
94
95 -#ifdef WITH_IDN
96 +#if defined (WITH_IDN) || defined (WITH_LIBIDN)
97 result = dns_name_settotextfilter(output_filter);
98 check_result(result, "dns_name_settotextfilter");
99 #endif
100 -
101 REQUIRE(lookup != NULL);
102 INSIST(!free_now);
103
104 @@ -2000,6 +2025,14 @@ setup_lookup(dig_lookup_t *lookup) {
105 mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, lookup->textname,
106 utf8_textname, sizeof(utf8_textname));
107 idn_check_result(mr, "convert textname to UTF-8");
108 +#elif defined (WITH_LIBIDN)
109 + result = libidn_locale_to_utf8 (lookup->textname, utf8_str);
110 + check_result (result, "convert textname to UTF-8");
111 + len = strlen (utf8_str);
112 + if (len < MXNAME)
113 + (void) strcpy (utf8_name, utf8_str);
114 + else
115 + fatal ("Too long name");
116 #endif
117
118 /*
119 @@ -2012,15 +2045,11 @@ setup_lookup(dig_lookup_t *lookup) {
120 if (lookup->new_search) {
121 #ifdef WITH_IDN
122 if ((count_dots(utf8_textname) >= ndots) || !usesearch) {
123 - lookup->origin = NULL; /* Force abs lookup */
124 - lookup->done_as_is = ISC_TRUE;
125 - lookup->need_search = usesearch;
126 - } else if (lookup->origin == NULL && usesearch) {
127 - lookup->origin = ISC_LIST_HEAD(search_list);
128 - lookup->need_search = ISC_FALSE;
129 - }
130 +#elif defined (WITH_LIBIDN)
131 + if ((count_dots(utf8_name) >= ndots) || !usesearch) {
132 #else
133 if ((count_dots(lookup->textname) >= ndots) || !usesearch) {
134 +#endif
135 lookup->origin = NULL; /* Force abs lookup */
136 lookup->done_as_is = ISC_TRUE;
137 lookup->need_search = usesearch;
138 @@ -2028,7 +2057,6 @@ setup_lookup(dig_lookup_t *lookup) {
139 lookup->origin = ISC_LIST_HEAD(search_list);
140 lookup->need_search = ISC_FALSE;
141 }
142 -#endif
143 }
144
145 #ifdef WITH_IDN
146 @@ -2045,6 +2073,20 @@ setup_lookup(dig_lookup_t *lookup) {
147 IDN_IDNCONV | IDN_LENCHECK, utf8_textname,
148 idn_textname, sizeof(idn_textname));
149 idn_check_result(mr, "convert UTF-8 textname to IDN encoding");
150 +#elif defined (WITH_LIBIDN)
151 + if (lookup->origin != NULL) {
152 + result = libidn_locale_to_utf8 (lookup->origin->origin, utf8_str);
153 + check_result (result, "convert origin to UTF-8");
154 + if (len > 0 && utf8_name[len - 1] != '.') {
155 + utf8_name[len++] = '.';
156 + if (len + strlen (utf8_str) < MXNAME)
157 + (void) strcpy (utf8_name + len, utf8_str);
158 + else
159 + fatal ("Too long name + origin");
160 + }
161 + }
162 +
163 + result = libidn_utf8_to_ascii (utf8_name, ascii_name);
164 #else
165 if (lookup->origin != NULL) {
166 debug("trying origin %s", lookup->origin->origin);
167 @@ -2100,6 +2142,13 @@ setup_lookup(dig_lookup_t *lookup) {
168 result = dns_name_fromtext(lookup->name, &b,
169 dns_rootname, 0,
170 &lookup->namebuf);
171 +#elif defined (WITH_LIBIDN)
172 + len = strlen (ascii_name);
173 + isc_buffer_init(&b, ascii_name, len);
174 + isc_buffer_add(&b, len);
175 + result = dns_name_fromtext(lookup->name, &b,
176 + dns_rootname, 0,
177 + &lookup->namebuf);
178 #else
179 len = strlen(lookup->textname);
180 isc_buffer_init(&b, lookup->textname, len);
181 @@ -3625,7 +3674,7 @@ destroy_libs(void) {
182 void * ptr;
183 dig_message_t *chase_msg;
184 #endif
185 -#ifdef WITH_IDN
186 +#if defined (WITH_IDN) || defined (WITH_LIBIDN)
187 isc_result_t result;
188 #endif
189
190 @@ -3664,6 +3713,10 @@ destroy_libs(void) {
191 result = dns_name_settotextfilter(NULL);
192 check_result(result, "dns_name_settotextfilter");
193 #endif
194 +#ifdef WITH_LIBIDN
195 + result = dns_name_settotextfilter (NULL);
196 + check_result(result, "clearing dns_name_settotextfilter");
197 +#endif
198 dns_name_destroy();
199
200 if (commctx != NULL) {
201 @@ -3842,6 +3895,97 @@ idn_check_result(idn_result_t r, const c
202 }
203 }
204 #endif /* WITH_IDN */
205 +#ifdef WITH_LIBIDN
206 +static isc_result_t
207 +libidn_locale_to_utf8 (const char *from, char *to) {
208 + char *utf8_str;
209 +
210 + debug ("libidn_locale_to_utf8");
211 + utf8_str = stringprep_locale_to_utf8 (from);
212 + if (utf8_str != NULL) {
213 + (void) strcpy (to, utf8_str);
214 + free (utf8_str);
215 + return ISC_R_SUCCESS;
216 + }
217 +
218 + debug ("libidn_locale_to_utf8: failure");
219 + return ISC_R_FAILURE;
220 +}
221 +static isc_result_t
222 +libidn_utf8_to_ascii (const char *from, char *to) {
223 + char *ascii;
224 + int iresult;
225 +
226 + debug ("libidn_utf8_to_ascii");
227 + iresult = idna_to_ascii_8z (from, &ascii, 0);
228 + if (iresult != IDNA_SUCCESS) {
229 + debug ("idna_to_ascii_8z: %s", idna_strerror (iresult));
230 + return ISC_R_FAILURE;
231 + }
232 +
233 + (void) strcpy (to, ascii);
234 + free (ascii);
235 + return ISC_R_SUCCESS;
236 +}
237 +
238 +static isc_result_t
239 +output_filter (isc_buffer_t *buffer, unsigned int used_org,
240 + isc_boolean_t absolute) {
241 +
242 + char tmp1[MXNAME], *tmp2;
243 + size_t fromlen, tolen;
244 + isc_boolean_t end_with_dot;
245 + int iresult;
246 +
247 + debug ("output_filter");
248 +
249 + fromlen = isc_buffer_usedlength (buffer) - used_org;
250 + if (fromlen >= MXNAME)
251 + return ISC_R_SUCCESS;
252 + memcpy (tmp1, (char *) isc_buffer_base (buffer) + used_org, fromlen);
253 + end_with_dot = (tmp1[fromlen - 1] == '.') ? ISC_TRUE : ISC_FALSE;
254 + if (absolute && !end_with_dot) {
255 + fromlen++;
256 + if (fromlen >= MXNAME)
257 + return ISC_R_SUCCESS;
258 + tmp1[fromlen - 1] = '.';
259 + }
260 + tmp1[fromlen] = '\0';
261 +
262 + iresult = idna_to_unicode_8z8z (tmp1, &tmp2, 0);
263 + if (iresult != IDNA_SUCCESS) {
264 + debug ("output_filter: %s", idna_strerror (iresult));
265 + return ISC_R_SUCCESS;
266 + }
267 +
268 + (void) strcpy (tmp1, tmp2);
269 + free (tmp2);
270 +
271 + tmp2 = stringprep_utf8_to_locale (tmp1);
272 + if (tmp2 == NULL) {
273 + debug ("output_filter: stringprep_utf8_to_locale failed");
274 + return ISC_R_SUCCESS;
275 + }
276 +
277 + (void) strcpy (tmp1, tmp2);
278 + free (tmp2);
279 +
280 + tolen = strlen (tmp1);
281 + if (absolute && !end_with_dot && tmp1[tolen - 1] == '.')
282 + tolen--;
283 +
284 + if (isc_buffer_length (buffer) < used_org + tolen)
285 + return ISC_R_NOSPACE;
286 +
287 + debug ("%s", tmp1);
288 +
289 + isc_buffer_subtract (buffer, isc_buffer_usedlength (buffer) - used_org);
290 + memcpy (isc_buffer_used (buffer), tmp1, tolen);
291 + isc_buffer_add (buffer, tolen);
292 +
293 + return ISC_R_SUCCESS;
294 +}
295 +#endif /* WITH_LIBIDN*/
296
297 #ifdef DIG_SIGCHASE
298 void
This page took 0.044537 seconds and 5 git commands to generate.