diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-03-08 16:26:58 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-03-08 16:43:05 +0100 |
commit | 02a56bb50dbdda2c38c197e76a27d7ed03ec3083 (patch) | |
tree | 6dd878b38e75cbe14dcf875738352cc08ada1abc /src/gns | |
parent | 800d91ce4366fbe4cfa6d7cf3f1bcb341f15d077 (diff) | |
download | gnunet-02a56bb50dbdda2c38c197e76a27d7ed03ec3083.tar.gz gnunet-02a56bb50dbdda2c38c197e76a27d7ed03ec3083.zip |
fix off-by-one in BOX type processing
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index ef191bbb3..0b86ca267 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1497,7 +1497,6 @@ handle_gns_resolution_result (void *cls, | |||
1497 | struct GNS_ResolverHandle *rh = cls; | 1497 | struct GNS_ResolverHandle *rh = cls; |
1498 | struct AuthorityChain *ac; | 1498 | struct AuthorityChain *ac; |
1499 | struct AuthorityChain *shorten_ac; | 1499 | struct AuthorityChain *shorten_ac; |
1500 | unsigned int i; | ||
1501 | char *cname; | 1500 | char *cname; |
1502 | struct VpnContext *vpn_ctx; | 1501 | struct VpnContext *vpn_ctx; |
1503 | const struct GNUNET_TUN_GnsVpnRecord *vpn; | 1502 | const struct GNUNET_TUN_GnsVpnRecord *vpn; |
@@ -1546,7 +1545,7 @@ handle_gns_resolution_result (void *cls, | |||
1546 | if ( (GNUNET_DNSPARSER_TYPE_A == rh->record_type) || | 1545 | if ( (GNUNET_DNSPARSER_TYPE_A == rh->record_type) || |
1547 | (GNUNET_DNSPARSER_TYPE_AAAA == rh->record_type) ) | 1546 | (GNUNET_DNSPARSER_TYPE_AAAA == rh->record_type) ) |
1548 | { | 1547 | { |
1549 | for (i=0;i<rd_count;i++) | 1548 | for (unsigned int i=0;i<rd_count;i++) |
1550 | { | 1549 | { |
1551 | switch (rd[i].record_type) | 1550 | switch (rd[i].record_type) |
1552 | { | 1551 | { |
@@ -1617,13 +1616,15 @@ handle_gns_resolution_result (void *cls, | |||
1617 | scratch_off = 0; | 1616 | scratch_off = 0; |
1618 | rd_off = 0; | 1617 | rd_off = 0; |
1619 | shorten_ac = rh->ac_tail; | 1618 | shorten_ac = rh->ac_tail; |
1620 | for (i=0;i<rd_count;i++) | 1619 | for (unsigned int i=0;i<rd_count;i++) |
1621 | { | 1620 | { |
1621 | GNUNET_assert (rd_off <= i); | ||
1622 | if ( (0 != rh->protocol) && | 1622 | if ( (0 != rh->protocol) && |
1623 | (0 != rh->service) && | 1623 | (0 != rh->service) && |
1624 | (GNUNET_GNSRECORD_TYPE_BOX != rd[i].record_type) ) | 1624 | (GNUNET_GNSRECORD_TYPE_BOX != rd[i].record_type) ) |
1625 | continue; /* we _only_ care about boxed records */ | 1625 | continue; /* we _only_ care about boxed records */ |
1626 | 1626 | ||
1627 | GNUNET_assert (rd_off < rd_count); | ||
1627 | rd_new[rd_off] = rd[i]; | 1628 | rd_new[rd_off] = rd[i]; |
1628 | /* Check if the embedded name(s) end in "+", and if so, | 1629 | /* Check if the embedded name(s) end in "+", and if so, |
1629 | replace the "+" with the zone at "ac_tail", changing the name | 1630 | replace the "+" with the zone at "ac_tail", changing the name |
@@ -1659,6 +1660,7 @@ handle_gns_resolution_result (void *cls, | |||
1659 | } | 1660 | } |
1660 | else | 1661 | else |
1661 | { | 1662 | { |
1663 | GNUNET_assert (rd_off < rd_count); | ||
1662 | rd_new[rd_off].data = &scratch[scratch_start]; | 1664 | rd_new[rd_off].data = &scratch[scratch_start]; |
1663 | rd_new[rd_off].data_size = scratch_off - scratch_start; | 1665 | rd_new[rd_off].data_size = scratch_off - scratch_start; |
1664 | rd_off++; | 1666 | rd_off++; |
@@ -1695,6 +1697,7 @@ handle_gns_resolution_result (void *cls, | |||
1695 | } | 1697 | } |
1696 | else | 1698 | else |
1697 | { | 1699 | { |
1700 | GNUNET_assert (rd_off < rd_count); | ||
1698 | rd_new[rd_off].data = &scratch[scratch_start]; | 1701 | rd_new[rd_off].data = &scratch[scratch_start]; |
1699 | rd_new[rd_off].data_size = scratch_off - scratch_start; | 1702 | rd_new[rd_off].data_size = scratch_off - scratch_start; |
1700 | rd_off++; | 1703 | rd_off++; |
@@ -1731,6 +1734,7 @@ handle_gns_resolution_result (void *cls, | |||
1731 | } | 1734 | } |
1732 | else | 1735 | else |
1733 | { | 1736 | { |
1737 | GNUNET_assert (rd_off < rd_count); | ||
1734 | rd_new[rd_off].data = &scratch[scratch_start]; | 1738 | rd_new[rd_off].data = &scratch[scratch_start]; |
1735 | rd_new[rd_off].data_size = scratch_off - scratch_start; | 1739 | rd_new[rd_off].data_size = scratch_off - scratch_start; |
1736 | rd_off++; | 1740 | rd_off++; |
@@ -1767,6 +1771,7 @@ handle_gns_resolution_result (void *cls, | |||
1767 | } | 1771 | } |
1768 | else | 1772 | else |
1769 | { | 1773 | { |
1774 | GNUNET_assert (rd_off < rd_count); | ||
1770 | rd_new[rd_off].data = &scratch[scratch_start]; | 1775 | rd_new[rd_off].data = &scratch[scratch_start]; |
1771 | rd_new[rd_off].data_size = scratch_off - scratch_start; | 1776 | rd_new[rd_off].data_size = scratch_off - scratch_start; |
1772 | rd_off++; | 1777 | rd_off++; |
@@ -1850,6 +1855,7 @@ handle_gns_resolution_result (void *cls, | |||
1850 | (ntohs (box->service) == rh->service) ) | 1855 | (ntohs (box->service) == rh->service) ) |
1851 | { | 1856 | { |
1852 | /* Box matches, unbox! */ | 1857 | /* Box matches, unbox! */ |
1858 | GNUNET_assert (rd_off < rd_count); | ||
1853 | rd_new[rd_off].record_type = ntohl (box->record_type); | 1859 | rd_new[rd_off].record_type = ntohl (box->record_type); |
1854 | rd_new[rd_off].data_size -= sizeof (struct GNUNET_GNSRECORD_BoxRecord); | 1860 | rd_new[rd_off].data_size -= sizeof (struct GNUNET_GNSRECORD_BoxRecord); |
1855 | rd_new[rd_off].data = &box[1]; | 1861 | rd_new[rd_off].data = &box[1]; |
@@ -1862,6 +1868,7 @@ handle_gns_resolution_result (void *cls, | |||
1862 | records (for modern, GNS-enabled applications) */ | 1868 | records (for modern, GNS-enabled applications) */ |
1863 | rd_off++; | 1869 | rd_off++; |
1864 | } | 1870 | } |
1871 | break; | ||
1865 | } | 1872 | } |
1866 | default: | 1873 | default: |
1867 | rd_off++; | 1874 | rd_off++; |
@@ -1882,7 +1889,7 @@ handle_gns_resolution_result (void *cls, | |||
1882 | } | 1889 | } |
1883 | do_recurse: | 1890 | do_recurse: |
1884 | /* need to recurse, check if we can */ | 1891 | /* need to recurse, check if we can */ |
1885 | for (i=0;i<rd_count;i++) | 1892 | for (unsigned int i=0;i<rd_count;i++) |
1886 | { | 1893 | { |
1887 | switch (rd[i].record_type) | 1894 | switch (rd[i].record_type) |
1888 | { | 1895 | { |
@@ -2064,7 +2071,9 @@ handle_gns_resolution_result (void *cls, | |||
2064 | } | 2071 | } |
2065 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2072 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2066 | _("GNS lookup recursion failed (no delegation record found)\n")); | 2073 | _("GNS lookup recursion failed (no delegation record found)\n")); |
2067 | rh->proc (rh->proc_cls, 0, NULL); | 2074 | rh->proc (rh->proc_cls, |
2075 | 0, | ||
2076 | NULL); | ||
2068 | GNS_resolver_lookup_cancel (rh); | 2077 | GNS_resolver_lookup_cancel (rh); |
2069 | } | 2078 | } |
2070 | 2079 | ||