aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-01-05 17:13:27 +0100
committerChristian Grothoff <christian@grothoff.org>2018-01-05 17:13:27 +0100
commit918491c8a9dd38cbe51dbdf2db650436ec63ac40 (patch)
tree954ed2ceb541aa4b7d806bacae4011a0085bebcc
parent7cad4a8604812fcea3178a6a6cb411b0237776ca (diff)
downloadgnunet-918491c8a9dd38cbe51dbdf2db650436ec63ac40.tar.gz
gnunet-918491c8a9dd38cbe51dbdf2db650436ec63ac40.zip
fix potential double free
-rw-r--r--src/gns/gnunet-service-gns_resolver.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index e14a05d45..5bf443267 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -327,7 +327,7 @@ struct GNS_ResolverHandle
327 /** 327 /**
328 * ID of a task associated with the resolution process. 328 * ID of a task associated with the resolution process.
329 */ 329 */
330 struct GNUNET_SCHEDULER_Task * task_id; 330 struct GNUNET_SCHEDULER_Task *task_id;
331 331
332 /** 332 /**
333 * The name to resolve 333 * The name to resolve
@@ -808,10 +808,10 @@ recursive_resolution (void *cls);
808 * Begin the resolution process from 'name', starting with 808 * Begin the resolution process from 'name', starting with
809 * the identification of the zone specified by 'name'. 809 * the identification of the zone specified by 'name'.
810 * 810 *
811 * @param rh resolution to perform 811 * @param cls closure with `struct GNS_ResolverHandle *rh`
812 */ 812 */
813static void 813static void
814start_resolver_lookup (struct GNS_ResolverHandle *rh); 814start_resolver_lookup (void *cls);
815 815
816 816
817/** 817/**
@@ -835,6 +835,7 @@ dns_result_parser (void *cls,
835 unsigned int rd_count; 835 unsigned int rd_count;
836 unsigned int i; 836 unsigned int i;
837 837
838 (void) rs;
838 rh->dns_request = NULL; 839 rh->dns_request = NULL;
839 GNUNET_SCHEDULER_cancel (rh->task_id); 840 GNUNET_SCHEDULER_cancel (rh->task_id);
840 rh->task_id = NULL; 841 rh->task_id = NULL;
@@ -859,7 +860,8 @@ dns_result_parser (void *cls,
859 GNUNET_free (rh->name); 860 GNUNET_free (rh->name);
860 rh->name = GNUNET_strdup (p->answers[0].data.hostname); 861 rh->name = GNUNET_strdup (p->answers[0].data.hostname);
861 rh->name_resolution_pos = strlen (rh->name); 862 rh->name_resolution_pos = strlen (rh->name);
862 start_resolver_lookup (rh); 863 rh->task_id = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
864 rh);
863 GNUNET_DNSPARSER_free_packet (p); 865 GNUNET_DNSPARSER_free_packet (p);
864 return; 866 return;
865 } 867 }
@@ -1141,7 +1143,8 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1141 GNUNET_free (rh->name); 1143 GNUNET_free (rh->name);
1142 rh->name = GNUNET_strdup (cname); 1144 rh->name = GNUNET_strdup (cname);
1143 rh->name_resolution_pos = strlen (rh->name); 1145 rh->name_resolution_pos = strlen (rh->name);
1144 start_resolver_lookup (rh); 1146 rh->task_id = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
1147 rh);
1145} 1148}
1146 1149
1147 1150
@@ -1839,7 +1842,9 @@ handle_gns_resolution_result (void *cls,
1839 g2dc->rh->options = GNUNET_GNS_LO_DEFAULT; 1842 g2dc->rh->options = GNUNET_GNS_LO_DEFAULT;
1840 g2dc->rh->loop_limiter = rh->loop_limiter + 1; 1843 g2dc->rh->loop_limiter = rh->loop_limiter + 1;
1841 rh->g2dc = g2dc; 1844 rh->g2dc = g2dc;
1842 start_resolver_lookup (g2dc->rh); 1845 g2dc->rh->task_id
1846 = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
1847 g2dc->rh);
1843 return; 1848 return;
1844 } 1849 }
1845 case GNUNET_DNSPARSER_TYPE_CNAME: 1850 case GNUNET_DNSPARSER_TYPE_CNAME:
@@ -1893,7 +1898,7 @@ namecache_cache_continuation (void *cls,
1893 struct CacheOps *co = cls; 1898 struct CacheOps *co = cls;
1894 1899
1895 co->namecache_qe_cache = NULL; 1900 co->namecache_qe_cache = NULL;
1896 if (NULL != emsg) 1901 if (GNUNET_OK != success)
1897 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1902 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1898 _("Failed to cache GNS resolution: %s\n"), 1903 _("Failed to cache GNS resolution: %s\n"),
1899 emsg); 1904 emsg);
@@ -1930,13 +1935,21 @@ handle_dht_response (void *cls,
1930 const struct GNUNET_PeerIdentity *put_path, 1935 const struct GNUNET_PeerIdentity *put_path,
1931 unsigned int put_path_length, 1936 unsigned int put_path_length,
1932 enum GNUNET_BLOCK_Type type, 1937 enum GNUNET_BLOCK_Type type,
1933 size_t size, const void *data) 1938 size_t size,
1939 const void *data)
1934{ 1940{
1935 struct GNS_ResolverHandle *rh = cls; 1941 struct GNS_ResolverHandle *rh = cls;
1936 struct AuthorityChain *ac = rh->ac_tail; 1942 struct AuthorityChain *ac = rh->ac_tail;
1937 const struct GNUNET_GNSRECORD_Block *block; 1943 const struct GNUNET_GNSRECORD_Block *block;
1938 struct CacheOps *co; 1944 struct CacheOps *co;
1939 1945
1946 (void) exp;
1947 (void) key;
1948 (void) get_path;
1949 (void) get_path_length;
1950 (void) put_path;
1951 (void) put_path_length;
1952 (void) type;
1940 GNUNET_DHT_get_stop (rh->get_handle); 1953 GNUNET_DHT_get_stop (rh->get_handle);
1941 rh->get_handle = NULL; 1954 rh->get_handle = NULL;
1942 GNUNET_CONTAINER_heap_remove_node (rh->dht_heap_node); 1955 GNUNET_CONTAINER_heap_remove_node (rh->dht_heap_node);
@@ -2239,16 +2252,18 @@ recursive_resolution (void *cls)
2239 * Begin the resolution process from 'name', starting with 2252 * Begin the resolution process from 'name', starting with
2240 * the identification of the zone specified by 'name'. 2253 * the identification of the zone specified by 'name'.
2241 * 2254 *
2242 * @param rh resolution to perform 2255 * @param cls the `struct GNS_ResolverHandle`
2243 */ 2256 */
2244static void 2257static void
2245start_resolver_lookup (struct GNS_ResolverHandle *rh) 2258start_resolver_lookup (void *cls)
2246{ 2259{
2260 struct GNS_ResolverHandle *rh = cls;
2247 struct AuthorityChain *ac; 2261 struct AuthorityChain *ac;
2248 char *y; 2262 char *y;
2249 struct in_addr v4; 2263 struct in_addr v4;
2250 struct in6_addr v6; 2264 struct in6_addr v6;
2251 2265
2266 rh->task_id = NULL;
2252 if (1 == inet_pton (AF_INET, 2267 if (1 == inet_pton (AF_INET,
2253 rh->name, 2268 rh->name,
2254 &v4)) 2269 &v4))
@@ -2388,7 +2403,8 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
2388 rh->record_type = record_type; 2403 rh->record_type = record_type;
2389 rh->name = GNUNET_strdup (name); 2404 rh->name = GNUNET_strdup (name);
2390 rh->name_resolution_pos = strlen (name); 2405 rh->name_resolution_pos = strlen (name);
2391 start_resolver_lookup (rh); 2406 rh->task_id = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
2407 rh);
2392 return rh; 2408 return rh;
2393} 2409}
2394 2410