diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-11-30 12:21:01 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-11-30 12:21:01 +0100 |
commit | 6495b7d3b6f83aa8c00dbdfde05c8609c22eb92b (patch) | |
tree | b778945dba342b1f892df81e7986195f14fd60f4 /src/gns | |
parent | e9ad4ee3550aeb0ff67fd98ddebafbd5f54dad3d (diff) | |
download | gnunet-6495b7d3b6f83aa8c00dbdfde05c8609c22eb92b.tar.gz gnunet-6495b7d3b6f83aa8c00dbdfde05c8609c22eb92b.zip |
fix GNS2DNS records for LSD001 UTF-8 change
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 6 | ||||
-rw-r--r-- | src/gns/nss/nss_gns_query.c | 2 | ||||
-rw-r--r-- | src/gns/plugin_gnsrecord_gns.c | 37 |
3 files changed, 39 insertions, 6 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 01af17fdc..fda2e69e0 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1697,9 +1697,15 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh, | |||
1697 | n = GNUNET_DNSPARSER_parse_name (rd[i].data, | 1697 | n = GNUNET_DNSPARSER_parse_name (rd[i].data, |
1698 | rd[i].data_size, | 1698 | rd[i].data_size, |
1699 | &off); | 1699 | &off); |
1700 | #ifndef LSD001 | ||
1701 | ip = GNUNET_strdup (&rd[i].data[off]); | ||
1702 | off += strlen (ip) + 1; | ||
1703 | #else | ||
1700 | ip = GNUNET_DNSPARSER_parse_name (rd[i].data, | 1704 | ip = GNUNET_DNSPARSER_parse_name (rd[i].data, |
1701 | rd[i].data_size, | 1705 | rd[i].data_size, |
1702 | &off); | 1706 | &off); |
1707 | #endif | ||
1708 | |||
1703 | if ((NULL == n) || | 1709 | if ((NULL == n) || |
1704 | (NULL == ip) || | 1710 | (NULL == ip) || |
1705 | (off != rd[i].data_size)) | 1711 | (off != rd[i].data_size)) |
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c index c79ae61f7..4f5f06cfa 100644 --- a/src/gns/nss/nss_gns_query.c +++ b/src/gns/nss/nss_gns_query.c | |||
@@ -72,7 +72,9 @@ gns_resolve_name (int af, const char *name, struct userdata *u) | |||
72 | { | 72 | { |
73 | char *argv[] = { "gnunet-gns", | 73 | char *argv[] = { "gnunet-gns", |
74 | "-r", //Raw output for easier parsing | 74 | "-r", //Raw output for easier parsing |
75 | #ifdef LSD001 | ||
75 | "-d", //DNS compatibility (allow IDNA names, no UTF-8) | 76 | "-d", //DNS compatibility (allow IDNA names, no UTF-8) |
77 | #endif | ||
76 | "-t", | 78 | "-t", |
77 | (AF_INET6 == af) ? "AAAA" : "A", | 79 | (AF_INET6 == af) ? "AAAA" : "A", |
78 | "-u", | 80 | "-u", |
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c index cffd5a965..52c35ce10 100644 --- a/src/gns/plugin_gnsrecord_gns.c +++ b/src/gns/plugin_gnsrecord_gns.c | |||
@@ -72,14 +72,25 @@ gns_value_to_string (void *cls, | |||
72 | 72 | ||
73 | off = 0; | 73 | off = 0; |
74 | ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off); | 74 | ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off); |
75 | if (NULL == ns) | ||
76 | { | ||
77 | GNUNET_break_op (0); | ||
78 | GNUNET_free_non_null (ns); | ||
79 | return NULL; | ||
80 | } | ||
81 | #ifndef LSD001 //DNS server IP/name must be UTF-8 | ||
82 | ip = GNUNET_strdup((char*) &data[off]); | ||
83 | #else | ||
84 | // Must be IP or DNS name | ||
75 | ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off); | 85 | ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off); |
76 | if ((NULL == ns) || (NULL == ip) || (off != data_size)) | 86 | if ((NULL == ip) || (off != data_size)) |
77 | { | 87 | { |
78 | GNUNET_break_op (0); | 88 | GNUNET_break_op (0); |
79 | GNUNET_free_non_null (ns); | 89 | GNUNET_free_non_null (ns); |
80 | GNUNET_free_non_null (ip); | 90 | GNUNET_free_non_null (ip); |
81 | return NULL; | 91 | return NULL; |
82 | } | 92 | } |
93 | #endif | ||
83 | GNUNET_asprintf (&nstr, "%s@%s", ns, ip); | 94 | GNUNET_asprintf (&nstr, "%s@%s", ns, ip); |
84 | GNUNET_free_non_null (ns); | 95 | GNUNET_free_non_null (ns); |
85 | GNUNET_free_non_null (ip); | 96 | GNUNET_free_non_null (ip); |
@@ -203,19 +214,33 @@ gns_string_to_value (void *cls, | |||
203 | at++; | 214 | at++; |
204 | 215 | ||
205 | off = 0; | 216 | off = 0; |
206 | if ((GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf, | 217 | if (GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf, |
207 | sizeof(nsbuf), | 218 | sizeof(nsbuf), |
208 | &off, | 219 | &off, |
209 | cpy)) || | 220 | cpy)) |
210 | (GNUNET_OK != | 221 | { |
211 | GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof(nsbuf), &off, at))) | 222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
223 | _ ( | ||
224 | "Failed to serialize GNS2DNS record with value `%s': Not a DNS name.\n"), | ||
225 | s); | ||
226 | GNUNET_free (cpy); | ||
227 | return GNUNET_SYSERR; | ||
228 | } | ||
229 | #ifndef LSD001 //The DNS server location/name is in UTF-8 | ||
230 | GNUNET_memcpy (&nsbuf[off], at, strlen (at) + 1); | ||
231 | off += strlen (at) + 1; | ||
232 | #else | ||
233 | if (GNUNET_OK != | ||
234 | GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof(nsbuf), &off, at)) | ||
212 | { | 235 | { |
213 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 236 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
214 | _ ("Failed to serialize GNS2DNS record with value `%s'\n"), | 237 | _ ( |
238 | "Failed to serialize GNS2DNS record with value `%s': Not a DNS name\n"), | ||
215 | s); | 239 | s); |
216 | GNUNET_free (cpy); | 240 | GNUNET_free (cpy); |
217 | return GNUNET_SYSERR; | 241 | return GNUNET_SYSERR; |
218 | } | 242 | } |
243 | #endif | ||
219 | GNUNET_free (cpy); | 244 | GNUNET_free (cpy); |
220 | *data_size = off; | 245 | *data_size = off; |
221 | *data = GNUNET_malloc (off); | 246 | *data = GNUNET_malloc (off); |