summaryrefslogtreecommitdiff
path: root/src/gns/gnunet-service-gns_resolver.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-11-06 20:58:36 +0000
committerChristian Grothoff <christian@grothoff.org>2013-11-06 20:58:36 +0000
commit2e945be53320104218989a255f68a8047aa996ac (patch)
tree883863d6bcdd626f789091c29df39bf62274116e /src/gns/gnunet-service-gns_resolver.c
parentf9b9e094e8bcacfe8d531994a8baaea94ed4b800 (diff)
downloadgnunet-2e945be53320104218989a255f68a8047aa996ac.tar.gz
gnunet-2e945be53320104218989a255f68a8047aa996ac.zip
-fix crash on GNS2DNS resolver completion, and properly translate names ending in .+, fixes #3093
Diffstat (limited to 'src/gns/gnunet-service-gns_resolver.c')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c60
1 files changed, 26 insertions, 34 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 28ec58430..2ab3c9a88 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1201,6 +1201,13 @@ handle_gns2dns_result (void *cls,
1201 size_t sa_len; 1201 size_t sa_len;
1202 1202
1203 /* find suitable A/AAAA record */ 1203 /* find suitable A/AAAA record */
1204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1205 "Received %u results for IP address of DNS server for GNS2DNS transition\n",
1206 rd_count);
1207 /* enable cleanup of 'rh' handle that comes next... */
1208 GNUNET_CONTAINER_DLL_insert (rlh_head,
1209 rlh_tail,
1210 rh->g2dc->rh);
1204 rh->g2dc->rh = NULL; 1211 rh->g2dc->rh = NULL;
1205 sa = NULL; 1212 sa = NULL;
1206 sa_len = 0; 1213 sa_len = 0;
@@ -1285,6 +1292,10 @@ handle_gns2dns_result (void *cls,
1285 GNUNET_free (rh->g2dc->ns); 1292 GNUNET_free (rh->g2dc->ns);
1286 GNUNET_free (rh->g2dc); 1293 GNUNET_free (rh->g2dc);
1287 rh->g2dc = NULL; 1294 rh->g2dc = NULL;
1295 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1296 "Will continue resolution using DNS server `%s' to resolve `%s'\n",
1297 GNUNET_a2s (sa, sa_len),
1298 ac->label);
1288 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 1299 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
1289 rh->ac_tail, 1300 rh->ac_tail,
1290 ac); 1301 ac);
@@ -1689,55 +1700,36 @@ handle_gns_resolution_result (void *cls,
1689 /* resolution continues within DNS */ 1700 /* resolution continues within DNS */
1690 struct Gns2DnsContext *g2dc; 1701 struct Gns2DnsContext *g2dc;
1691 char *ip; 1702 char *ip;
1692 char *at;
1693 char *cp;
1694 char *ns; 1703 char *ns;
1695 1704
1696 cp = GNUNET_strndup (rd[i].data,
1697 rd[i].data_size);
1698 at = strchr (cp, '@');
1699 if (NULL == at)
1700 {
1701 GNUNET_break_op (0);
1702 rh->proc (rh->proc_cls, 0, NULL);
1703 GNS_resolver_lookup_cancel (rh);
1704 return;
1705 }
1706 *at = '\0';
1707 off = 0; 1705 off = 0;
1708 ns = GNUNET_DNSPARSER_parse_name (cp, 1706 ns = GNUNET_DNSPARSER_parse_name (rd[i].data,
1709 strlen (cp), 1707 rd[i].data_size,
1710 &off); 1708 &off);
1711 if ( (NULL == ns) || 1709 ip = GNUNET_DNSPARSER_parse_name (rd[i].data,
1712 (off != strlen (cp)) ) 1710 rd[i].data_size,
1713 {
1714 GNUNET_break_op (0); /* record not well-formed */
1715 rh->proc (rh->proc_cls, 0, NULL);
1716 GNS_resolver_lookup_cancel (rh);
1717 GNUNET_free (cp);
1718 return;
1719 }
1720 off++; /* skip '@' */
1721 ip = GNUNET_DNSPARSER_parse_name (cp,
1722 strlen (at + 1),
1723 &off); 1711 &off);
1724 if ( (NULL == ip) || 1712 if ( (NULL == ns) ||
1713 (NULL == ip) ||
1725 (off != rd[i].data_size) ) 1714 (off != rd[i].data_size) )
1726 { 1715 {
1727 GNUNET_break_op (0); /* record not well-formed */ 1716 GNUNET_break_op (0);
1728 rh->proc (rh->proc_cls, 0, NULL); 1717 GNUNET_free_non_null (ns);
1729 GNS_resolver_lookup_cancel (rh); 1718 GNUNET_free_non_null (ip);
1730 GNUNET_free (ns); 1719 rh->proc (rh->proc_cls, 0, NULL);
1731 GNUNET_free (cp); 1720 GNS_resolver_lookup_cancel (rh);
1732 return; 1721 return;
1733 } 1722 }
1734 GNUNET_free (cp); 1723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1724 "Resolving `%s' to determine IP address of DNS server for GNS2DNS transition\n",
1725 ip);
1735 /* resolve 'ip' to determine the IP(s) of the DNS 1726 /* resolve 'ip' to determine the IP(s) of the DNS
1736 resolver to use */ 1727 resolver to use */
1737 g2dc = GNUNET_new (struct Gns2DnsContext); 1728 g2dc = GNUNET_new (struct Gns2DnsContext);
1738 g2dc->ns = ns; 1729 g2dc->ns = ns;
1739 g2dc->rh = GNUNET_new (struct GNS_ResolverHandle); 1730 g2dc->rh = GNUNET_new (struct GNS_ResolverHandle);
1740 g2dc->rh->authority_zone = rh->ac_tail->authority_info.gns_authority; 1731 g2dc->rh->authority_zone = rh->ac_tail->authority_info.gns_authority;
1732 ip = translate_dot_plus (rh, ip);
1741 g2dc->rh->name = ip; 1733 g2dc->rh->name = ip;
1742 g2dc->rh->name_resolution_pos = strlen (ip); 1734 g2dc->rh->name_resolution_pos = strlen (ip);
1743 g2dc->rh->proc = &handle_gns2dns_result; 1735 g2dc->rh->proc = &handle_gns2dns_result;