summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-11-30 12:21:01 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-11-30 12:21:01 +0100
commit6495b7d3b6f83aa8c00dbdfde05c8609c22eb92b (patch)
treeb778945dba342b1f892df81e7986195f14fd60f4
parente9ad4ee3550aeb0ff67fd98ddebafbd5f54dad3d (diff)
fix GNS2DNS records for LSD001 UTF-8 change
-rw-r--r--src/gns/gnunet-service-gns_resolver.c6
-rw-r--r--src/gns/nss/nss_gns_query.c2
-rw-r--r--src/gns/plugin_gnsrecord_gns.c37
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,
n = GNUNET_DNSPARSER_parse_name (rd[i].data,
rd[i].data_size,
&off);
+#ifndef LSD001
+ ip = GNUNET_strdup (&rd[i].data[off]);
+ off += strlen (ip) + 1;
+#else
ip = GNUNET_DNSPARSER_parse_name (rd[i].data,
rd[i].data_size,
&off);
+#endif
+
if ((NULL == n) ||
(NULL == ip) ||
(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)
{
char *argv[] = { "gnunet-gns",
"-r", //Raw output for easier parsing
+#ifdef LSD001
"-d", //DNS compatibility (allow IDNA names, no UTF-8)
+#endif
"-t",
(AF_INET6 == af) ? "AAAA" : "A",
"-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,
off = 0;
ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
+ if (NULL == ns)
+ {
+ GNUNET_break_op (0);
+ GNUNET_free_non_null (ns);
+ return NULL;
+ }
+#ifndef LSD001 //DNS server IP/name must be UTF-8
+ ip = GNUNET_strdup((char*) &data[off]);
+#else
+ // Must be IP or DNS name
ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
- if ((NULL == ns) || (NULL == ip) || (off != data_size))
+ if ((NULL == ip) || (off != data_size))
{
GNUNET_break_op (0);
GNUNET_free_non_null (ns);
GNUNET_free_non_null (ip);
return NULL;
}
+#endif
GNUNET_asprintf (&nstr, "%s@%s", ns, ip);
GNUNET_free_non_null (ns);
GNUNET_free_non_null (ip);
@@ -203,19 +214,33 @@ gns_string_to_value (void *cls,
at++;
off = 0;
- if ((GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf,
+ if (GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (nsbuf,
sizeof(nsbuf),
&off,
- cpy)) ||
- (GNUNET_OK !=
- GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof(nsbuf), &off, at)))
+ cpy))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ (
+ "Failed to serialize GNS2DNS record with value `%s': Not a DNS name.\n"),
+ s);
+ GNUNET_free (cpy);
+ return GNUNET_SYSERR;
+ }
+#ifndef LSD001 //The DNS server location/name is in UTF-8
+ GNUNET_memcpy (&nsbuf[off], at, strlen (at) + 1);
+ off += strlen (at) + 1;
+#else
+ if (GNUNET_OK !=
+ GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof(nsbuf), &off, at))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to serialize GNS2DNS record with value `%s'\n"),
+ _ (
+ "Failed to serialize GNS2DNS record with value `%s': Not a DNS name\n"),
s);
GNUNET_free (cpy);
return GNUNET_SYSERR;
}
+#endif
GNUNET_free (cpy);
*data_size = off;
*data = GNUNET_malloc (off);