diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-03-26 10:13:29 +0100 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-03-26 10:13:29 +0100 |
commit | b23c010728c1c808796a7948aa7ff9f9a08966ac (patch) | |
tree | 6fab9793c1c40bd4c443c2ece2f9e79465a64fe1 | |
parent | 85288987ac9b78e2a1617379e4600d6644199e26 (diff) | |
download | gnunet-b23c010728c1c808796a7948aa7ff9f9a08966ac.tar.gz gnunet-b23c010728c1c808796a7948aa7ff9f9a08966ac.zip |
-fix some coverity issues wrt gns
-rw-r--r-- | src/gns/gnunet-dns2gns.c | 8 | ||||
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 23 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_interceptor.c | 1 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 27 | ||||
-rw-r--r-- | src/gns/plugin_rest_gns.c | 4 | ||||
-rw-r--r-- | src/gnsrecord/gnsrecord_misc.c | 2 | ||||
-rw-r--r-- | src/gnsrecord/gnunet-gnsrecord-tvg.c | 2 |
7 files changed, 45 insertions, 22 deletions
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 0a9b7c861..06f4c9841 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c | |||
@@ -309,6 +309,14 @@ dns_result_processor (void *cls, | |||
309 | } | 309 | } |
310 | request->packet = GNUNET_DNSPARSER_parse ((char *) dns, | 310 | request->packet = GNUNET_DNSPARSER_parse ((char *) dns, |
311 | r); | 311 | r); |
312 | if (NULL == request->packet) | ||
313 | { | ||
314 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
315 | _ ("Failed to parse DNS response!\n")); | ||
316 | GNUNET_SCHEDULER_cancel (request->timeout_task); | ||
317 | do_timeout (request); | ||
318 | return; | ||
319 | } | ||
312 | GNUNET_DNSSTUB_resolve_cancel (request->dns_lookup); | 320 | GNUNET_DNSSTUB_resolve_cancel (request->dns_lookup); |
313 | send_response (request); | 321 | send_response (request); |
314 | } | 322 | } |
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 833a8da01..d02f0f576 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -1841,6 +1841,7 @@ create_response (void *cls, | |||
1841 | char *curlurl; | 1841 | char *curlurl; |
1842 | char ipstring[INET6_ADDRSTRLEN]; | 1842 | char ipstring[INET6_ADDRSTRLEN]; |
1843 | char ipaddr[INET6_ADDRSTRLEN + 2]; | 1843 | char ipaddr[INET6_ADDRSTRLEN + 2]; |
1844 | char *curl_hosts; | ||
1844 | const struct sockaddr *sa; | 1845 | const struct sockaddr *sa; |
1845 | const struct sockaddr_in *s4; | 1846 | const struct sockaddr_in *s4; |
1846 | const struct sockaddr_in6 *s6; | 1847 | const struct sockaddr_in6 *s6; |
@@ -1900,6 +1901,14 @@ create_response (void *cls, | |||
1900 | GNUNET_break (0); | 1901 | GNUNET_break (0); |
1901 | return MHD_NO; | 1902 | return MHD_NO; |
1902 | } | 1903 | } |
1904 | GNUNET_asprintf (&curl_hosts, | ||
1905 | "%s:%d:%s", | ||
1906 | s5r->leho, | ||
1907 | port, | ||
1908 | ipaddr); | ||
1909 | s5r->hosts = curl_slist_append (NULL, | ||
1910 | curl_hosts); | ||
1911 | GNUNET_free (curl_hosts); | ||
1903 | } | 1912 | } |
1904 | else | 1913 | else |
1905 | { | 1914 | { |
@@ -1949,21 +1958,13 @@ create_response (void *cls, | |||
1949 | * Pre-populate cache to resolve Hostname. | 1958 | * Pre-populate cache to resolve Hostname. |
1950 | * This is necessary as the DNS name in the CURLOPT_URL is used | 1959 | * This is necessary as the DNS name in the CURLOPT_URL is used |
1951 | * for SNI http://de.wikipedia.org/wiki/Server_Name_Indication | 1960 | * for SNI http://de.wikipedia.org/wiki/Server_Name_Indication |
1952 | */if (NULL != s5r->leho) | 1961 | */ |
1962 | if ((NULL != s5r->leho) && | ||
1963 | (NULL != s5r->hosts)) | ||
1953 | { | 1964 | { |
1954 | char *curl_hosts; | ||
1955 | |||
1956 | GNUNET_asprintf (&curl_hosts, | ||
1957 | "%s:%d:%s", | ||
1958 | s5r->leho, | ||
1959 | port, | ||
1960 | ipaddr); | ||
1961 | s5r->hosts = curl_slist_append (NULL, | ||
1962 | curl_hosts); | ||
1963 | curl_easy_setopt (s5r->curl, | 1965 | curl_easy_setopt (s5r->curl, |
1964 | CURLOPT_RESOLVE, | 1966 | CURLOPT_RESOLVE, |
1965 | s5r->hosts); | 1967 | s5r->hosts); |
1966 | GNUNET_free (curl_hosts); | ||
1967 | } | 1968 | } |
1968 | if (s5r->is_gns) | 1969 | if (s5r->is_gns) |
1969 | { | 1970 | { |
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c index b53f4af6b..255f85598 100644 --- a/src/gns/gnunet-service-gns_interceptor.c +++ b/src/gns/gnunet-service-gns_interceptor.c | |||
@@ -323,7 +323,6 @@ handle_dns_request (void *cls, | |||
323 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 323 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
324 | "Received malformed DNS packet, leaving it untouched.\n"); | 324 | "Received malformed DNS packet, leaving it untouched.\n"); |
325 | GNUNET_DNS_request_forward (rh); | 325 | GNUNET_DNS_request_forward (rh); |
326 | GNUNET_DNSPARSER_free_packet (p); | ||
327 | return; | 326 | return; |
328 | } | 327 | } |
329 | 328 | ||
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 49c1b340a..2f8a55804 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -764,6 +764,7 @@ transmit_lookup_dns_result (struct GNS_ResolverHandle *rh) | |||
764 | rd[i].data = pos->data; | 764 | rd[i].data = pos->data; |
765 | rd[i].data_size = pos->data_size; | 765 | rd[i].data_size = pos->data_size; |
766 | rd[i].record_type = pos->record_type; | 766 | rd[i].record_type = pos->record_type; |
767 | rd[i].flags = GNUNET_GNSRECORD_RF_NONE; | ||
767 | /** | 768 | /** |
768 | * If this is a LEHO, we added this before. It must be a supplemental | 769 | * If this is a LEHO, we added this before. It must be a supplemental |
769 | * record #LSD0001 | 770 | * record #LSD0001 |
@@ -772,12 +773,11 @@ transmit_lookup_dns_result (struct GNS_ResolverHandle *rh) | |||
772 | rd[i].flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL; | 773 | rd[i].flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL; |
773 | if (0 == pos->expiration_time) | 774 | if (0 == pos->expiration_time) |
774 | { | 775 | { |
775 | rd[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 776 | rd[i].flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
776 | rd[i].expiration_time = 0; | 777 | rd[i].expiration_time = 0; |
777 | } | 778 | } |
778 | else | 779 | else |
779 | { | 780 | { |
780 | rd[i].flags = GNUNET_GNSRECORD_RF_NONE; | ||
781 | rd[i].expiration_time = pos->expiration_time; | 781 | rd[i].expiration_time = pos->expiration_time; |
782 | } | 782 | } |
783 | i++; | 783 | i++; |
@@ -1764,6 +1764,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh, | |||
1764 | /** | 1764 | /** |
1765 | * Records other than GNS2DNS not allowed | 1765 | * Records other than GNS2DNS not allowed |
1766 | */ | 1766 | */ |
1767 | if (NULL != ns) | ||
1768 | GNUNET_free (ns); | ||
1767 | return GNUNET_SYSERR; | 1769 | return GNUNET_SYSERR; |
1768 | } | 1770 | } |
1769 | off = 0; | 1771 | off = 0; |
@@ -1771,15 +1773,22 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh, | |||
1771 | rd[i].data_size, | 1773 | rd[i].data_size, |
1772 | &off); | 1774 | &off); |
1773 | ip = GNUNET_strdup (&((const char *) rd[i].data)[off]); | 1775 | ip = GNUNET_strdup (&((const char *) rd[i].data)[off]); |
1776 | if ((NULL == n) || | ||
1777 | (NULL == ip)) | ||
1778 | { | ||
1779 | GNUNET_break_op (0); | ||
1780 | if (NULL != n) | ||
1781 | GNUNET_free (n); | ||
1782 | if (NULL != ip) | ||
1783 | GNUNET_free (ip); | ||
1784 | continue; | ||
1785 | } | ||
1786 | |||
1774 | off += strlen (ip) + 1; | 1787 | off += strlen (ip) + 1; |
1775 | 1788 | ||
1776 | if ((NULL == n) || | 1789 | if (off != rd[i].data_size) |
1777 | (NULL == ip) || | ||
1778 | (off != rd[i].data_size)) | ||
1779 | { | 1790 | { |
1780 | GNUNET_break_op (0); | 1791 | GNUNET_break_op (0); |
1781 | GNUNET_free (n); | ||
1782 | GNUNET_free (ip); | ||
1783 | continue; | 1792 | continue; |
1784 | } | 1793 | } |
1785 | /* resolve 'ip' to determine the IP(s) of the DNS | 1794 | /* resolve 'ip' to determine the IP(s) of the DNS |
@@ -1909,6 +1918,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh, | |||
1909 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1918 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1910 | _ ("Name `%s' cannot be converted to IDNA."), | 1919 | _ ("Name `%s' cannot be converted to IDNA."), |
1911 | tmp); | 1920 | tmp); |
1921 | GNUNET_free (tmp); | ||
1922 | GNUNET_free (ac); | ||
1912 | return GNUNET_SYSERR; | 1923 | return GNUNET_SYSERR; |
1913 | } | 1924 | } |
1914 | GNUNET_free (tmp); | 1925 | GNUNET_free (tmp); |
@@ -1922,6 +1933,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh, | |||
1922 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1933 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1923 | _ ("GNS lookup resulted in DNS name that is too long (`%s')\n"), | 1934 | _ ("GNS lookup resulted in DNS name that is too long (`%s')\n"), |
1924 | ac->label); | 1935 | ac->label); |
1936 | GNUNET_free (ac->label); | ||
1937 | GNUNET_free (ac); | ||
1925 | return GNUNET_SYSERR; | 1938 | return GNUNET_SYSERR; |
1926 | } | 1939 | } |
1927 | continue_with_gns2dns (ac); | 1940 | continue_with_gns2dns (ac); |
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c index 2ccb5be2b..3a35c9999 100644 --- a/src/gns/plugin_rest_gns.c +++ b/src/gns/plugin_rest_gns.c | |||
@@ -270,7 +270,9 @@ handle_gns_response (void *cls, | |||
270 | result = json_dumps (result_obj, 0); | 270 | result = json_dumps (result_obj, 0); |
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); |
272 | resp = GNUNET_REST_create_response (result); | 272 | resp = GNUNET_REST_create_response (result); |
273 | MHD_add_response_header (resp, "Content-Type", "application/json"); | 273 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, |
274 | "Content-Type", | ||
275 | "application/json")); | ||
274 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 276 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
275 | GNUNET_free (result); | 277 | GNUNET_free (result); |
276 | json_decref (result_obj); | 278 | json_decref (result_obj); |
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index 82c38f19a..dacd7ca31 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c | |||
@@ -350,7 +350,7 @@ GNUNET_GNSRECORD_block_get_expiration (const struct | |||
350 | case GNUNET_GNSRECORD_TYPE_PKEY: | 350 | case GNUNET_GNSRECORD_TYPE_PKEY: |
351 | return GNUNET_TIME_absolute_ntoh (block->ecdsa_block.expiration_time); | 351 | return GNUNET_TIME_absolute_ntoh (block->ecdsa_block.expiration_time); |
352 | default: | 352 | default: |
353 | return GNUNET_TIME_absolute_get_zero_ (); | 353 | GNUNET_break (0); /* Hopefully we never get here, but we might */ |
354 | } | 354 | } |
355 | return GNUNET_TIME_absolute_get_zero_ (); | 355 | return GNUNET_TIME_absolute_get_zero_ (); |
356 | 356 | ||
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c b/src/gnsrecord/gnunet-gnsrecord-tvg.c index 47b13bdab..d6b35544c 100644 --- a/src/gnsrecord/gnunet-gnsrecord-tvg.c +++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c | |||
@@ -172,7 +172,7 @@ run (void *cls, | |||
172 | fprintf (stdout, "RRBLOCK:\n"); | 172 | fprintf (stdout, "RRBLOCK:\n"); |
173 | print_bytes (rrblock, block_size, 8); | 173 | print_bytes (rrblock, block_size, 8); |
174 | fprintf (stdout, "\n"); | 174 | fprintf (stdout, "\n"); |
175 | 175 | GNUNET_free (rdata); | |
176 | } | 176 | } |
177 | 177 | ||
178 | 178 | ||