/[packages]/updates/5/bind/current/SOURCES/bind-9.5-libidn2.patch
ViewVC logotype

Contents of /updates/5/bind/current/SOURCES/bind-9.5-libidn2.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1104818 - (show annotations) (download)
Fri May 26 13:25:52 2017 UTC (6 years, 10 months ago) by guillomovitch
File size: 7339 byte(s)
- sync with cauldron packages, to fix multiple security issues
 (CVE-2016-931, CVE-2016-9147, CVE-2016-9444, CVE-2017-3135) (#mga20107)
- also ensure /dev/urandom is available in chroot (#mga12425)

1 diff -Naurp bind-9.9.5/bin/dig/dighost.c bind-9.9.5.oden/bin/dig/dighost.c
2 --- bind-9.9.5/bin/dig/dighost.c 2014-02-02 13:58:37.507244365 +0100
3 +++ bind-9.9.5.oden/bin/dig/dighost.c 2014-02-02 13:58:48.478244978 +0100
4 @@ -167,7 +167,7 @@ isc_socket_t *keep = NULL;
5 isc_sockaddr_t keepaddr;
6
7 #ifdef WITH_LIBIDN
8 -static isc_result_t libidn_locale_to_utf8 (const char* from, char **to);
9 +static isc_result_t libidn_locale_to_utf8 (const char* from, char *to);
10 static isc_result_t libidn_utf8_to_ascii (const char* from, char *to);
11 static isc_result_t output_filter (isc_buffer_t *buffer,
12 unsigned int used_org,
13 @@ -2052,18 +2052,14 @@ setup_lookup(dig_lookup_t *lookup) {
14 char utf8_textname[MXNAME], utf8_origin[MXNAME], idn_textname[MXNAME];
15 #endif
16 #ifdef WITH_LIBIDN
17 - char *utf8_str = NULL, utf8_name[MXNAME], ascii_name[MXNAME];
18 + char utf8_str[MXNAME], utf8_name[MXNAME], ascii_name[MXNAME];
19 #endif
20
21 -#ifdef WITH_IDN
22 +#if defined (WITH_IDN) || defined (WITH_LIBIDN)
23 result = dns_name_settotextfilter(lookup->idnout ?
24 output_filter : NULL);
25 check_result(result, "dns_name_settotextfilter");
26 #endif
27 -#ifdef WITH_LIBIDN
28 - result = dns_name_settotextfilter (output_filter);
29 - check_result(result, "dns_name_settotextfilter");
30 -#endif
31 REQUIRE(lookup != NULL);
32 INSIST(!free_now);
33
34 @@ -2100,15 +2096,13 @@ setup_lookup(dig_lookup_t *lookup) {
35 utf8_textname, sizeof(utf8_textname));
36 idn_check_result(mr, "convert textname to UTF-8");
37 #elif defined (WITH_LIBIDN)
38 - result = libidn_locale_to_utf8 (lookup->textname, &utf8_str);
39 - check_result (result, "converting textname to UTF-8");
40 + result = libidn_locale_to_utf8 (lookup->textname, utf8_str);
41 + check_result (result, "convert textname to UTF-8");
42 len = strlen (utf8_str);
43 - if (len < MXNAME) {
44 + if (len < MXNAME)
45 (void) strcpy (utf8_name, utf8_str);
46 - } else {
47 + else
48 fatal ("Too long name");
49 - }
50 - isc_mem_free (mctx, utf8_str);
51 #endif
52
53 /*
54 @@ -2121,24 +2115,11 @@ setup_lookup(dig_lookup_t *lookup) {
55 if (lookup->new_search) {
56 #ifdef WITH_IDN
57 if ((count_dots(utf8_textname) >= ndots) || !usesearch) {
58 - lookup->origin = NULL; /* Force abs lookup */
59 - lookup->done_as_is = ISC_TRUE;
60 - lookup->need_search = usesearch;
61 - } else if (lookup->origin == NULL && usesearch) {
62 - lookup->origin = ISC_LIST_HEAD(search_list);
63 - lookup->need_search = ISC_FALSE;
64 - }
65 #elif defined (WITH_LIBIDN)
66 if ((count_dots(utf8_name) >= ndots) || !usesearch) {
67 - lookup->origin = NULL; /* Force abs lookup */
68 - lookup->done_as_is = ISC_TRUE;
69 - lookup->need_search = usesearch;
70 - } else if (lookup->origin == NULL && usesearch) {
71 - lookup->origin = ISC_LIST_HEAD(search_list);
72 - lookup->need_search = ISC_FALSE;
73 - }
74 #else
75 if ((count_dots(lookup->textname) >= ndots) || !usesearch) {
76 +#endif
77 lookup->origin = NULL; /* Force abs lookup */
78 lookup->done_as_is = ISC_TRUE;
79 lookup->need_search = usesearch;
80 @@ -2146,7 +2127,6 @@ setup_lookup(dig_lookup_t *lookup) {
81 lookup->origin = ISC_LIST_HEAD(search_list);
82 lookup->need_search = ISC_FALSE;
83 }
84 -#endif
85 }
86
87 #ifdef WITH_IDN
88 @@ -2165,15 +2145,12 @@ setup_lookup(dig_lookup_t *lookup) {
89 idn_check_result(mr, "convert UTF-8 textname to IDN encoding");
90 #elif defined (WITH_LIBIDN)
91 if (lookup->origin != NULL) {
92 - result = libidn_locale_to_utf8 (lookup->origin->origin, &utf8_str);
93 + result = libidn_locale_to_utf8 (lookup->origin->origin, utf8_str);
94 check_result (result, "convert origin to UTF-8");
95 - if (len + strlen (utf8_str) + 1 < MXNAME) {
96 - utf8_name[len++] = '.';
97 + if (len + strlen (utf8_str) < MXNAME)
98 (void) strcpy (utf8_name + len, utf8_str);
99 - } else {
100 + else
101 fatal ("Too long name + origin");
102 - }
103 - isc_mem_free (mctx, utf8_str);
104 }
105
106 result = libidn_utf8_to_ascii (utf8_name, ascii_name);
107 @@ -4082,76 +4059,85 @@ idn_check_result(idn_result_t r, const c
108 }
109 #endif /* WITH_IDN */
110 #ifdef WITH_LIBIDN
111 -/* If stringprep_locale_to_utf8 fails simple copy string */
112 static isc_result_t
113 -libidn_locale_to_utf8 (const char *from, char **to) {
114 +libidn_locale_to_utf8 (const char *from, char *to) {
115 char *utf8_str;
116
117 + debug ("libidn_locale_to_utf8");
118 utf8_str = stringprep_locale_to_utf8 (from);
119 - if (utf8_str == NULL) {
120 - *to = isc_mem_allocate (mctx, strlen (from) + 1);
121 - if (*to == NULL)
122 - return (ISC_R_NOMEMORY);
123 - (void) strcpy (*to, from);
124 - } else {
125 - *to = isc_mem_allocate (mctx, strlen (utf8_str) + 1);
126 - if (*to == NULL)
127 - return (ISC_R_NOMEMORY);
128 - (void) strcpy (*to, utf8_str);
129 + if (utf8_str != NULL) {
130 + (void) strcpy (to, utf8_str);
131 free (utf8_str);
132 + return ISC_R_SUCCESS;
133 }
134 - return (ISC_R_SUCCESS);
135 +
136 + debug ("libidn_locale_to_utf8: failure");
137 + return ISC_R_FAILURE;
138 }
139 static isc_result_t
140 libidn_utf8_to_ascii (const char *from, char *to) {
141 char *ascii;
142 + int iresult;
143
144 - if (idna_to_ascii_8z (from, &ascii, 0) != IDNA_SUCCESS)
145 - return (ISC_R_FAILURE);
146 + debug ("libidn_utf8_to_ascii");
147 + iresult = idna_to_ascii_8z (from, &ascii, 0);
148 + if (iresult != IDNA_SUCCESS) {
149 + debug ("idna_to_ascii_8z: %s", idna_strerror (iresult));
150 + return ISC_R_FAILURE;
151 + }
152
153 (void) strcpy (to, ascii);
154 free (ascii);
155 - return (ISC_R_SUCCESS);
156 + return ISC_R_SUCCESS;
157 }
158 -/* based on idnkit's code*/
159 +
160 static isc_result_t
161 output_filter (isc_buffer_t *buffer, unsigned int used_org,
162 isc_boolean_t absolute) {
163 +
164 char tmp1[MXNAME], *tmp2;
165 size_t fromlen, tolen;
166 isc_boolean_t end_with_dot;
167 + int iresult;
168 +
169 + debug ("output_filter");
170
171 - fromlen = isc_buffer_usedlength(buffer) - used_org;
172 + fromlen = isc_buffer_usedlength (buffer) - used_org;
173 if (fromlen >= MXNAME)
174 - return (ISC_R_SUCCESS);
175 - memcpy(tmp1, (char *)isc_buffer_base(buffer) + used_org, fromlen);
176 + return ISC_R_SUCCESS;
177 + memcpy (tmp1, (char *) isc_buffer_base (buffer) + used_org, fromlen);
178 end_with_dot = (tmp1[fromlen - 1] == '.') ? ISC_TRUE : ISC_FALSE;
179 if (absolute && !end_with_dot) {
180 fromlen++;
181 if (fromlen >= MXNAME)
182 - return (ISC_R_SUCCESS);
183 + return ISC_R_SUCCESS;
184 tmp1[fromlen - 1] = '.';
185 }
186 tmp1[fromlen] = '\0';
187
188 - if (idna_to_unicode_lzlz (tmp1, &tmp2, 0) != IDNA_SUCCESS)
189 - return (ISC_R_SUCCESS);
190 + iresult = idna_to_unicode_8z8z (tmp1, &tmp2, 0);
191 + if (iresult != IDNA_SUCCESS) {
192 + debug ("output_filter: %s", idna_strerror (iresult));
193 + return ISC_R_SUCCESS;
194 + }
195
196 (void) strcpy (tmp1, tmp2);
197 free (tmp2);
198
199 - tolen = strlen(tmp1);
200 + tolen = strlen (tmp1);
201 if (absolute && !end_with_dot && tmp1[tolen - 1] == '.')
202 tolen--;
203
204 - if (isc_buffer_length(buffer) < used_org + tolen)
205 - return (ISC_R_NOSPACE);
206 + if (isc_buffer_length (buffer) < used_org + tolen)
207 + return ISC_R_NOSPACE;
208 +
209 + debug ("%s", tmp1);
210
211 - isc_buffer_subtract(buffer, isc_buffer_usedlength(buffer) - used_org);
212 - memcpy(isc_buffer_used(buffer), tmp1, tolen);
213 - isc_buffer_add(buffer, tolen);
214 + isc_buffer_subtract (buffer, isc_buffer_usedlength (buffer) - used_org);
215 + memcpy (isc_buffer_used (buffer), tmp1, tolen);
216 + isc_buffer_add (buffer, tolen);
217
218 - return (ISC_R_SUCCESS);
219 + return ISC_R_SUCCESS;
220 }
221 #endif /* WITH_LIBIDN*/
222

  ViewVC Help
Powered by ViewVC 1.1.30