aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.mailmap17
-rw-r--r--AUTHORS6
-rw-r--r--src/abd/gnunet-abd.c2
-rw-r--r--src/arm/gnunet-arm.c4
-rw-r--r--src/ats-tool/gnunet-ats.c2
-rw-r--r--src/auction/gnunet-auction-create.c2
-rw-r--r--src/auction/gnunet-auction-info.c2
-rw-r--r--src/auction/gnunet-auction-join.c2
-rw-r--r--src/cadet/gnunet-cadet.c2
-rw-r--r--src/conversation/gnunet-conversation-test.c2
-rw-r--r--src/conversation/gnunet-conversation.c2
-rw-r--r--src/core/gnunet-core.c2
-rw-r--r--src/curl/curl.c37
-rw-r--r--src/datastore/gnunet-datastore.c2
-rw-r--r--src/dns/gnunet-dns-monitor.c2
-rw-r--r--src/dns/gnunet-dns-redirector.c2
-rw-r--r--src/fs/gnunet-auto-share.c2
-rw-r--r--src/fs/gnunet-directory.c2
-rw-r--r--src/fs/gnunet-download.c2
-rw-r--r--src/fs/gnunet-fs-profiler.c2
-rw-r--r--src/fs/gnunet-fs.c2
-rw-r--r--src/fs/gnunet-publish.c2
-rw-r--r--src/fs/gnunet-search.c2
-rw-r--r--src/fs/gnunet-unindex.c2
-rw-r--r--src/gns/gnunet-bcd.c2
-rw-r--r--src/gns/gnunet-dns2gns.c2
-rw-r--r--src/gns/gnunet-gns-benchmark.c2
-rw-r--r--src/gns/gnunet-gns-import.c2
-rw-r--r--src/gns/gnunet-gns.c2
-rw-r--r--src/gnsrecord/perf_gnsrecord_crypto.c2
-rw-r--r--src/gnsrecord/test_gnsrecord_serialization.c2
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c2
-rw-r--r--src/identity/gnunet-identity.c2
-rw-r--r--src/include/gnunet_common.h63
-rw-r--r--src/include/gnunet_json_lib.h34
-rw-r--r--src/json/Makefile.am1
-rw-r--r--src/json/json_gnsrecord.c4
-rw-r--r--src/json/json_helper.c107
-rw-r--r--src/json/test_json_mhd.c3
-rw-r--r--src/namecache/gnunet-namecache.c4
-rw-r--r--src/namecache/test_namecache_api_cache_block.c19
-rw-r--r--src/namestore/gnunet-namestore-fcfsd.c2
-rw-r--r--src/namestore/gnunet-namestore.c4
-rw-r--r--src/namestore/gnunet-zoneimport.c2
-rw-r--r--src/namestore/plugin_rest_namestore.c2
-rw-r--r--src/namestore/test_namestore_api_lookup_private.c2
-rw-r--r--src/namestore/test_namestore_api_lookup_public.c2
-rw-r--r--src/namestore/test_namestore_api_lookup_shadow.c2
-rw-r--r--src/namestore/test_namestore_api_lookup_shadow_filter.c4
-rw-r--r--src/namestore/test_namestore_api_monitoring.c6
-rw-r--r--src/namestore/test_namestore_api_monitoring_existing.c6
-rw-r--r--src/namestore/test_namestore_api_remove.c2
-rw-r--r--src/namestore/test_namestore_api_store.c2
-rw-r--r--src/namestore/test_namestore_api_store_update.c2
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c42
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_nick.c6
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_specific_zone.c6
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c45
-rw-r--r--src/nat-auto/gnunet-nat-auto.c2
-rw-r--r--src/nat/gnunet-nat.c2
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c2
-rw-r--r--src/peerinfo-tool/plugin_rest_peerinfo.c2
-rw-r--r--src/pt/gnunet-daemon-pt.c2
-rw-r--r--src/pt/test_gns_vpn.c5
-rw-r--r--src/pt/test_gnunet_vpn.c3
-rw-r--r--src/regex/gnunet-daemon-regexprofiler.c2
-rw-r--r--src/revocation/gnunet-revocation.c2
-rw-r--r--src/statistics/gnunet-statistics.c2
-rw-r--r--src/template/gnunet-template.c2
-rw-r--r--src/testbed/gnunet-daemon-latency-logger.c2
-rw-r--r--src/testbed/gnunet-daemon-testbed-blacklist.c2
-rw-r--r--src/testbed/gnunet-daemon-testbed-underlay.c2
-rw-r--r--src/testbed/gnunet-testbed-profiler.c2
-rw-r--r--src/testing/gnunet-testing.c2
-rw-r--r--src/testing/testing.c2
-rw-r--r--src/topology/gnunet-daemon-topology.c2
-rw-r--r--src/transport/gnunet-communicator-tcp.c2
-rw-r--r--src/transport/gnunet-communicator-udp.c2
-rw-r--r--src/transport/gnunet-communicator-unix.c2
-rw-r--r--src/transport/gnunet-transport-profiler.c2
-rw-r--r--src/transport/gnunet-transport.c2
-rw-r--r--src/transport/tcp_service_legacy.c4
-rw-r--r--src/transport/test_plugin_transport.c14
-rw-r--r--src/util/gnunet-config.c2
-rw-r--r--src/util/gnunet-ecc.c2
-rw-r--r--src/util/gnunet-resolver.c12
-rw-r--r--src/util/gnunet-scrypt.c2
-rw-r--r--src/util/gnunet-uri.c2
-rw-r--r--src/util/os_priority.c2
-rw-r--r--src/util/scheduler.c10
-rw-r--r--src/util/test_common_allocation.c26
-rw-r--r--src/vpn/gnunet-vpn.c2
92 files changed, 421 insertions, 201 deletions
diff --git a/.mailmap b/.mailmap
index e15a72268..2ca867b4e 100644
--- a/.mailmap
+++ b/.mailmap
@@ -14,14 +14,15 @@ Jeffrey Burdges <burdges@gnunet.org>
14Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> 14Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>
15Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Schanzenbach, Martin <mschanzenbach@posteo.de> 15Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Schanzenbach, Martin <mschanzenbach@posteo.de>
16Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Martin Schanzenbach <mschanzenbach@posteo.de> 16Martin Schanzenbach <martin.schanzenbach@aisec.fraunhofer.de> Martin Schanzenbach <mschanzenbach@posteo.de>
17nikita <tek.no.katze@gmail.com> ng0@n0.is <ng0@n0.is> 17nikita <nikita@n0.is>
18nikita <tek.no.katze@gmail.com> ng0 <ng0@n0.is> 18nikita <nikita@n0.is> nikita <tek.no.katze@gmail.com>
19nikita <tek.no.katze@gmail.com> 19nikita <nikita@n0.is> ng0@n0.is <ng0@n0.is>
20nikita <tek.no.katze@gmail.com> ng0 <contact.ng0@cryptolab.net> 20nikita <nikita@n0.is> ng0 <ng0@n0.is>
21nikita <tek.no.katze@gmail.com> ng0 <ng0@infotropique.org> 21nikita <nikita@n0.is> ng0 <contact.ng0@cryptolab.net>
22nikita <tek.no.katze@gmail.com> N. 'ng0' Gillmann <ngillmann@runbox.com> 22nikita <nikita@n0.is> ng0 <ng0@infotropique.org>
23nikita <tek.no.katze@gmail.com> ng0 <ng0@we.make.ritual.n0.is> 23nikita <nikita@n0.is> N. 'ng0' Gillmann <ngillmann@runbox.com>
24nikita <tek.no.katze@gmail.com> Nils Gillmann <ng0@n0.is> 24nikita <nikita@n0.is> ng0 <ng0@we.make.ritual.n0.is>
25nikita <nikita@n0.is> Nils Gillmann <ng0@n0.is>
25t3sserakt <t3ss@posteo.de> 26t3sserakt <t3ss@posteo.de>
26t3sserakt <t3ss@posteo.de> <t3sserakt@posteo.de> 27t3sserakt <t3ss@posteo.de> <t3sserakt@posteo.de>
27tg(x) <*@tg-x.net> 28tg(x) <*@tg-x.net>
diff --git a/AUTHORS b/AUTHORS
index d44dc3920..061d51379 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -70,7 +70,7 @@ Marko Räihä
70Michael John Wensley <michael@wensley.org.uk> 70Michael John Wensley <michael@wensley.org.uk>
71Milan Bouchet-Valat <nalimilan@club.fr> 71Milan Bouchet-Valat <nalimilan@club.fr>
72Nathan Evans <evans@net.in.tum.de> 72Nathan Evans <evans@net.in.tum.de>
73Nils Gillmann <ng0@n0.is> [ Documentation export to Texinfo ] 73nikita <nikita@n0.is> [ Documentation export to Texinfo ]
74Paul Ruth <ruth@cs.purdue.edu> 74Paul Ruth <ruth@cs.purdue.edu>
75Philipp Tölke <toelke@in.tum.de>, <pt@philipptoelke.de> 75Philipp Tölke <toelke@in.tum.de>, <pt@philipptoelke.de>
76Renaldo Ferreira <rf@cs.purdue.edu> 76Renaldo Ferreira <rf@cs.purdue.edu>
@@ -124,8 +124,8 @@ Nix: viric, rahul
124OpenWrt/LEDE: Daniel Golle <daniel@makrotopia.org> 124OpenWrt/LEDE: Daniel Golle <daniel@makrotopia.org>
125macOS: Jussi Eloranta <eloranta@cc.jyu.fi> 125macOS: Jussi Eloranta <eloranta@cc.jyu.fi>
126Gentoo: Carlo von lynX <psyc://loupsycedyglgamf.onion/~lynX> 126Gentoo: Carlo von lynX <psyc://loupsycedyglgamf.onion/~lynX>
127 N. Gillmann <ng0@n0.is> 127 nikita <nikita@n0.is>
128NetBSD pkgsrc: N. Gillmann <ng0@n0.is> 128NetBSD pkgsrc: nikita <nikita@NetBSD.org>
129 129
130If you have contributed and are not listed here, please 130If you have contributed and are not listed here, please
131notify one of the maintainers in order to be added. 131notify one of the maintainers in order to be added.
diff --git a/src/abd/gnunet-abd.c b/src/abd/gnunet-abd.c
index a5d32c3dd..eb3e29e23 100644
--- a/src/abd/gnunet-abd.c
+++ b/src/abd/gnunet-abd.c
@@ -1074,7 +1074,7 @@ main (int argc, char *const *argv)
1074 &run, 1074 &run,
1075 NULL)) 1075 NULL))
1076 ret = 1; 1076 ret = 1;
1077 GNUNET_free ((void *) argv); 1077 GNUNET_free_nz ((void *) argv);
1078 return ret; 1078 return ret;
1079} 1079}
1080 1080
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 3b4e770b0..ea3a012ab 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -1054,10 +1054,10 @@ main (int argc, char *const *argv)
1054 &run, 1054 &run,
1055 NULL))) 1055 NULL)))
1056 { 1056 {
1057 GNUNET_free ((void *) argv); 1057 GNUNET_free_nz ((void *) argv);
1058 return ret; 1058 return ret;
1059 } 1059 }
1060 GNUNET_free ((void *) argv); 1060 GNUNET_free_nz ((void *) argv);
1061 return lret; 1061 return lret;
1062} 1062}
1063 1063
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c
index 16636e505..947ed7798 100644
--- a/src/ats-tool/gnunet-ats.c
+++ b/src/ats-tool/gnunet-ats.c
@@ -980,7 +980,7 @@ main (int argc, char *const *argv)
980 NULL); 980 NULL);
981 GNUNET_free_non_null (opt_pid_str); 981 GNUNET_free_non_null (opt_pid_str);
982 GNUNET_free_non_null (opt_type_str); 982 GNUNET_free_non_null (opt_type_str);
983 GNUNET_free ((void *) argv); 983 GNUNET_free_nz ((void *) argv);
984 984
985 if (GNUNET_OK == res) 985 if (GNUNET_OK == res)
986 return ret; 986 return ret;
diff --git a/src/auction/gnunet-auction-create.c b/src/auction/gnunet-auction-create.c
index 79106d8e8..93947b89c 100644
--- a/src/auction/gnunet-auction-create.c
+++ b/src/auction/gnunet-auction-create.c
@@ -214,6 +214,6 @@ main (int argc, char *const *argv)
214 options, 214 options,
215 &run, 215 &run,
216 NULL)) ? ret : 1; 216 NULL)) ? ret : 1;
217 GNUNET_free ((void *) argv); 217 GNUNET_free_nz ((void *) argv);
218 return ret; 218 return ret;
219} 219}
diff --git a/src/auction/gnunet-auction-info.c b/src/auction/gnunet-auction-info.c
index f20565835..dded45ce6 100644
--- a/src/auction/gnunet-auction-info.c
+++ b/src/auction/gnunet-auction-info.c
@@ -78,7 +78,7 @@ main (int argc, char *const *argv)
78 options, 78 options,
79 &run, 79 &run,
80 NULL)) ? ret : 1; 80 NULL)) ? ret : 1;
81 GNUNET_free ((void *) argv); 81 GNUNET_free_nz ((void *) argv);
82 return ret; 82 return ret;
83} 83}
84 84
diff --git a/src/auction/gnunet-auction-join.c b/src/auction/gnunet-auction-join.c
index f20565835..dded45ce6 100644
--- a/src/auction/gnunet-auction-join.c
+++ b/src/auction/gnunet-auction-join.c
@@ -78,7 +78,7 @@ main (int argc, char *const *argv)
78 options, 78 options,
79 &run, 79 &run,
80 NULL)) ? ret : 1; 80 NULL)) ? ret : 1;
81 GNUNET_free ((void *) argv); 81 GNUNET_free_nz ((void *) argv);
82 return ret; 82 return ret;
83} 83}
84 84
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index f3ccd9883..9b7538ae7 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -840,7 +840,7 @@ main (int argc, char *const *argv)
840 &run, 840 &run,
841 NULL); 841 NULL);
842 842
843 GNUNET_free ((void *) argv); 843 GNUNET_free_nz ((void *) argv);
844 844
845 if (GNUNET_OK == res) 845 if (GNUNET_OK == res)
846 return 0; 846 return 0;
diff --git a/src/conversation/gnunet-conversation-test.c b/src/conversation/gnunet-conversation-test.c
index 2e6772d92..9f8e54033 100644
--- a/src/conversation/gnunet-conversation-test.c
+++ b/src/conversation/gnunet-conversation-test.c
@@ -257,7 +257,7 @@ main (int argc,
257 options, 257 options,
258 &run, 258 &run,
259 NULL)) ? ret : 1; 259 NULL)) ? ret : 1;
260 GNUNET_free ((void *) argv); 260 GNUNET_free_nz ((void *) argv);
261 return ret; 261 return ret;
262} 262}
263 263
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c
index 6c0a6e42f..b908cd82c 100644
--- a/src/conversation/gnunet-conversation.c
+++ b/src/conversation/gnunet-conversation.c
@@ -1219,7 +1219,7 @@ main (int argc, char *const *argv)
1219 options, 1219 options,
1220 &run, 1220 &run,
1221 NULL); 1221 NULL);
1222 GNUNET_free ((void *) argv); 1222 GNUNET_free_nz ((void *) argv);
1223 if (NULL != cfg) 1223 if (NULL != cfg)
1224 { 1224 {
1225 GNUNET_CONFIGURATION_destroy (cfg); 1225 GNUNET_CONFIGURATION_destroy (cfg);
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index 90777a7a8..d90c8e1f5 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -198,7 +198,7 @@ main (int argc, char *const *argv)
198 &run, 198 &run,
199 NULL); 199 NULL);
200 200
201 GNUNET_free ((void *) argv); 201 GNUNET_free_nz ((void *) argv);
202 if (GNUNET_OK == res) 202 if (GNUNET_OK == res)
203 return 0; 203 return 0;
204 return 1; 204 return 1;
diff --git a/src/curl/curl.c b/src/curl/curl.c
index da486ecc1..72bb17789 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -526,6 +526,40 @@ GNUNET_CURL_job_cancel (struct GNUNET_CURL_Job *job)
526 526
527 527
528/** 528/**
529 * Test if the given content type @a ct is JSON
530 *
531 * @param ct a content type, i.e. "application/json; charset=UTF-8"
532 * @return true if @a ct denotes JSON
533 */
534static bool
535is_json (const char *ct)
536{
537 const char *semi;
538
539 /* check for "application/json" exact match */
540 if (0 == strcasecmp (ct,
541 "application/json"))
542 return true;
543 /* check for "application/json;[ANYTHING]" */
544 semi = strchr (ct,
545 ';');
546 /* also allow "application/json [ANYTHING]" (note the space!) */
547 if (NULL == semi)
548 semi = strchr (ct,
549 ' ');
550 if (NULL == semi)
551 return false; /* no delimiter we accept, forget it */
552 if (semi - ct != strlen ("application/json"))
553 return false; /* delimiter past desired length, forget it */
554 if (0 == strncasecmp (ct,
555 "application/json",
556 strlen ("application/json")))
557 return true; /* OK */
558 return false;
559}
560
561
562/**
529 * Obtain information about the final result about the 563 * Obtain information about the final result about the
530 * HTTP download. If the download was successful, parses 564 * HTTP download. If the download was successful, parses
531 * the JSON in the @a db and returns it. Also returns 565 * the JSON in the @a db and returns it. Also returns
@@ -562,8 +596,7 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db,
562 CURLINFO_CONTENT_TYPE, 596 CURLINFO_CONTENT_TYPE,
563 &ct)) || 597 &ct)) ||
564 (NULL == ct) || 598 (NULL == ct) ||
565 (0 != strcasecmp (ct, 599 (! is_json (ct)))
566 "application/json")))
567 { 600 {
568 /* No content type or explicitly not JSON, refuse to parse 601 /* No content type or explicitly not JSON, refuse to parse
569 (but keep response code) */ 602 (but keep response code) */
diff --git a/src/datastore/gnunet-datastore.c b/src/datastore/gnunet-datastore.c
index 54d087bc4..5901cce54 100644
--- a/src/datastore/gnunet-datastore.c
+++ b/src/datastore/gnunet-datastore.c
@@ -500,7 +500,7 @@ main (int argc, char *const *argv)
500 &run, 500 &run,
501 NULL)) 501 NULL))
502 ret = 1; 502 ret = 1;
503 GNUNET_free ((void *) argv); 503 GNUNET_free_nz ((void *) argv);
504 return ret; 504 return ret;
505} 505}
506 506
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c
index 7be792fc5..f6c0d0660 100644
--- a/src/dns/gnunet-dns-monitor.c
+++ b/src/dns/gnunet-dns-monitor.c
@@ -387,7 +387,7 @@ main (int argc, char *const *argv)
387 gettext_noop 387 gettext_noop
388 ("Monitor DNS queries."), options, 388 ("Monitor DNS queries."), options,
389 &run, NULL)) ? ret : 1; 389 &run, NULL)) ? ret : 1;
390 GNUNET_free ((void *) argv); 390 GNUNET_free_nz ((void *) argv);
391 return ret; 391 return ret;
392} 392}
393 393
diff --git a/src/dns/gnunet-dns-redirector.c b/src/dns/gnunet-dns-redirector.c
index f7051f70b..606864c8a 100644
--- a/src/dns/gnunet-dns-redirector.c
+++ b/src/dns/gnunet-dns-redirector.c
@@ -260,7 +260,7 @@ main (int argc, char *const *argv)
260 ("Change DNS replies to point elsewhere."), 260 ("Change DNS replies to point elsewhere."),
261 options, 261 options,
262 &run, NULL)) ? ret : 1; 262 &run, NULL)) ? ret : 1;
263 GNUNET_free ((void *) argv); 263 GNUNET_free_nz ((void *) argv);
264 return ret; 264 return ret;
265} 265}
266 266
diff --git a/src/fs/gnunet-auto-share.c b/src/fs/gnunet-auto-share.c
index 53c64ab04..13bc908e8 100644
--- a/src/fs/gnunet-auto-share.c
+++ b/src/fs/gnunet-auto-share.c
@@ -775,7 +775,7 @@ main (int argc, char *const *argv)
775 sigpipe = NULL; 775 sigpipe = NULL;
776 GNUNET_free_non_null (cfg_filename); 776 GNUNET_free_non_null (cfg_filename);
777 cfg_filename = NULL; 777 cfg_filename = NULL;
778 GNUNET_free ((void *) argv); 778 GNUNET_free_nz ((void *) argv);
779 return ok; 779 return ok;
780} 780}
781 781
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index 58950bceb..10a09f73b 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -203,7 +203,7 @@ main (int argc, char *const *argv)
203 NULL)) 203 NULL))
204 ? ret 204 ? ret
205 : 1; 205 : 1;
206 GNUNET_free ((void *) argv); 206 GNUNET_free_nz ((void *) argv);
207 return ret; 207 return ret;
208} 208}
209 209
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index 63bb02958..eebf8e993 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -376,7 +376,7 @@ main (int argc, char *const *argv)
376 NULL)) 376 NULL))
377 ? ret 377 ? ret
378 : 1; 378 : 1;
379 GNUNET_free ((void *) argv); 379 GNUNET_free_nz ((void *) argv);
380 return ret; 380 return ret;
381} 381}
382 382
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c
index fe86cf21f..62da46834 100644
--- a/src/fs/gnunet-fs-profiler.c
+++ b/src/fs/gnunet-fs-profiler.c
@@ -237,7 +237,7 @@ main (int argc, char *const *argv)
237 "run a testbed to measure file-sharing performance"), 237 "run a testbed to measure file-sharing performance"),
238 options, &run, 238 options, &run,
239 NULL)) ? ret : 1; 239 NULL)) ? ret : 1;
240 GNUNET_free ((void *) argv); 240 GNUNET_free_nz ((void *) argv);
241 return ret; 241 return ret;
242} 242}
243 243
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c
index 35d410d37..70a0034a0 100644
--- a/src/fs/gnunet-fs.c
+++ b/src/fs/gnunet-fs.c
@@ -144,7 +144,7 @@ main (int argc, char *const *argv)
144 NULL)) 144 NULL))
145 ? ret 145 ? ret
146 : 1; 146 : 1;
147 GNUNET_free ((void *) argv); 147 GNUNET_free_nz ((void *) argv);
148 return ret; 148 return ret;
149} 149}
150 150
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index ac310b785..b10e6163c 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -992,7 +992,7 @@ main (int argc, char *const *argv)
992 NULL)) 992 NULL))
993 ? ret 993 ? ret
994 : 1; 994 : 1;
995 GNUNET_free ((void *) argv); 995 GNUNET_free_nz ((void *) argv);
996 return ret; 996 return ret;
997} 997}
998 998
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index e0b9a31fd..098633379 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -371,7 +371,7 @@ main (int argc, char *const *argv)
371 NULL)) 371 NULL))
372 ? ret 372 ? ret
373 : 1; 373 : 1;
374 GNUNET_free ((void *) argv); 374 GNUNET_free_nz ((void *) argv);
375 return ret; 375 return ret;
376} 376}
377 377
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index bf32de812..afc547127 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -197,7 +197,7 @@ main (int argc, char *const *argv)
197 NULL)) 197 NULL))
198 ? ret 198 ? ret
199 : 1; 199 : 1;
200 GNUNET_free ((void *) argv); 200 GNUNET_free_nz ((void *) argv);
201 return ret; 201 return ret;
202} 202}
203 203
diff --git a/src/gns/gnunet-bcd.c b/src/gns/gnunet-bcd.c
index 6ceff4a9a..f71f477ef 100644
--- a/src/gns/gnunet-bcd.c
+++ b/src/gns/gnunet-bcd.c
@@ -525,7 +525,7 @@ main (int argc, char *const *argv)
525 NULL)) 525 NULL))
526 ? 0 526 ? 0
527 : 1; 527 : 1;
528 GNUNET_free ((void *) argv); 528 GNUNET_free_nz ((void *) argv);
529 return ret; 529 return ret;
530} 530}
531 531
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 8ec1f1cdb..eb9996b36 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -775,7 +775,7 @@ main (int argc,
775 _ ("GNUnet DNS-to-GNS proxy (a DNS server)"), 775 _ ("GNUnet DNS-to-GNS proxy (a DNS server)"),
776 options, 776 options,
777 &run, NULL)) ? 0 : 1; 777 &run, NULL)) ? 0 : 1;
778 GNUNET_free ((void *) argv); 778 GNUNET_free_nz ((void *) argv);
779 return ret; 779 return ret;
780} 780}
781 781
diff --git a/src/gns/gnunet-gns-benchmark.c b/src/gns/gnunet-gns-benchmark.c
index 0dcff7566..b36a83f21 100644
--- a/src/gns/gnunet-gns-benchmark.c
+++ b/src/gns/gnunet-gns-benchmark.c
@@ -610,7 +610,7 @@ main (int argc,
610 &run, 610 &run,
611 NULL)) 611 NULL))
612 ret = 1; 612 ret = 1;
613 GNUNET_free ((void *) argv); 613 GNUNET_free_nz ((void *) argv);
614 return ret; 614 return ret;
615} 615}
616 616
diff --git a/src/gns/gnunet-gns-import.c b/src/gns/gnunet-gns-import.c
index 0c104ee0d..2c7c56411 100644
--- a/src/gns/gnunet-gns-import.c
+++ b/src/gns/gnunet-gns-import.c
@@ -486,7 +486,7 @@ main (int argc, char *const *argv)
486 "This program will import some GNS authorities into your GNS namestore."), 486 "This program will import some GNS authorities into your GNS namestore."),
487 options, 487 options,
488 &run, NULL); 488 &run, NULL);
489 GNUNET_free ((void *) argv); 489 GNUNET_free_nz ((void *) argv);
490 return GNUNET_OK == r ? ret : 1; 490 return GNUNET_OK == r ? ret : 1;
491} 491}
492 492
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index d52761ef8..eb1d4f23f 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -376,7 +376,7 @@ main (int argc, char *const *argv)
376 options, 376 options,
377 &run, 377 &run,
378 NULL); 378 NULL);
379 GNUNET_free ((void *) argv); 379 GNUNET_free_nz ((void *) argv);
380 if (GNUNET_OK != ret) 380 if (GNUNET_OK != ret)
381 return 1; 381 return 1;
382 return global_ret; 382 return global_ret;
diff --git a/src/gnsrecord/perf_gnsrecord_crypto.c b/src/gnsrecord/perf_gnsrecord_crypto.c
index b2614eb77..eb4633f75 100644
--- a/src/gnsrecord/perf_gnsrecord_crypto.c
+++ b/src/gnsrecord/perf_gnsrecord_crypto.c
@@ -107,7 +107,7 @@ run (void *cls,
107 GNUNET_YES), 107 GNUNET_YES),
108 ROUNDS); 108 ROUNDS);
109 for (unsigned int i = 0; i < RECORDS; i++) 109 for (unsigned int i = 0; i < RECORDS; i++)
110 GNUNET_free ((void *) s_rd[i].data); 110 GNUNET_free_nz ((void *) s_rd[i].data);
111 GNUNET_free (s_rd); 111 GNUNET_free (s_rd);
112} 112}
113 113
diff --git a/src/gnsrecord/test_gnsrecord_serialization.c b/src/gnsrecord/test_gnsrecord_serialization.c
index 22d9f8396..d268cb7f3 100644
--- a/src/gnsrecord/test_gnsrecord_serialization.c
+++ b/src/gnsrecord/test_gnsrecord_serialization.c
@@ -132,7 +132,7 @@ run (void *cls,
132 132
133 for (c = 0; c < rd_count; c++) 133 for (c = 0; c < rd_count; c++)
134 { 134 {
135 GNUNET_free ((void *) src[c].data); 135 GNUNET_free_nz ((void *) src[c].data);
136 } 136 }
137} 137}
138 138
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index ca77545cd..704c796b4 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -409,7 +409,7 @@ main (int argc, char *const *argv)
409 _ ("GNUnet hostlist server and client"), 409 _ ("GNUnet hostlist server and client"),
410 options, 410 options,
411 &run, NULL)) ? 0 : 1; 411 &run, NULL)) ? 0 : 1;
412 GNUNET_free ((void *) argv); 412 GNUNET_free_nz ((void *) argv);
413 return ret; 413 return ret;
414} 414}
415 415
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c
index 1350376d9..8445a0ee5 100644
--- a/src/identity/gnunet-identity.c
+++ b/src/identity/gnunet-identity.c
@@ -439,7 +439,7 @@ main (int argc, char *const *argv)
439 options, 439 options,
440 &run, 440 &run,
441 NULL); 441 NULL);
442 GNUNET_free ((void *) argv); 442 GNUNET_free_nz ((void *) argv);
443 443
444 if (GNUNET_OK != res) 444 if (GNUNET_OK != res)
445 return 3; 445 return 3;
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 78aeb3de7..033a68894 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -1209,7 +1209,10 @@ GNUNET_is_zero_ (const void *a,
1209 * @param n number of elements in the array 1209 * @param n number of elements in the array
1210 * @param type name of the struct or union, i.e. pass 'struct Foo'. 1210 * @param type name of the struct or union, i.e. pass 'struct Foo'.
1211 */ 1211 */
1212#define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof(type)) 1212#define GNUNET_new_array(n, type) ({ \
1213 GNUNET_assert (SIZE_MAX / sizeof (type) >= n); \
1214 (type *) GNUNET_malloc ((n) * sizeof(type)); \
1215 })
1213 1216
1214/** 1217/**
1215 * @ingroup memory 1218 * @ingroup memory
@@ -1284,23 +1287,23 @@ GNUNET_is_zero_ (const void *a,
1284 * @ingroup memory 1287 * @ingroup memory
1285 * Wrapper around free. Frees the memory referred to by ptr. 1288 * Wrapper around free. Frees the memory referred to by ptr.
1286 * Note that it is generally better to free memory that was 1289 * Note that it is generally better to free memory that was
1287 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free. 1290 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free_nz.
1288 * 1291 *
1289 * @param ptr location where to free the memory. ptr must have 1292 * @param ptr location where to free the memory. ptr must have
1290 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. 1293 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier.
1291 */ 1294 */
1292#define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__) 1295#define GNUNET_free_nz(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__)
1293 1296
1294/** 1297/**
1295 * @ingroup memory 1298 * @ingroup memory
1296 * Wrapper around free. Frees the memory referred to by ptr and sets ptr to NULL. 1299 * Wrapper around free. Frees the memory referred to by ptr and sets ptr to NULL.
1297 * Note that it is generally better to free memory that was 1300 * Note that it is generally better to free memory that was
1298 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_freez. 1301 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free.
1299 * 1302 *
1300 * @param ptr location where to free the memory. ptr must have 1303 * @param ptr location where to free the memory. ptr must have
1301 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. 1304 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier.
1302 */ 1305 */
1303#define GNUNET_freez(ptr) do { \ 1306#define GNUNET_free(ptr) do { \
1304 GNUNET_xfree_ (ptr, __FILE__, __LINE__); \ 1307 GNUNET_xfree_ (ptr, __FILE__, __LINE__); \
1305 ptr = NULL; \ 1308 ptr = NULL; \
1306} while (0) 1309} while (0)
@@ -1389,22 +1392,58 @@ GNUNET_is_zero_ (const void *a,
1389 1392
1390/** 1393/**
1391 * @ingroup memory 1394 * @ingroup memory
1392 * Append an element to a list (growing the list by one). 1395 * Append an element to an array (growing the array by one).
1393 * 1396 *
1394 * @param arr base-pointer of the vector, may be NULL if size is 0; 1397 * @param arr base-pointer of the vector, may be NULL if @a len is 0;
1395 * will be updated to reflect the new address. The TYPE of 1398 * will be updated to reflect the new address. The TYPE of
1396 * arr is important since size is the number of elements and 1399 * arr is important since size is the number of elements and
1397 * not the size in bytes 1400 * not the size in bytes
1398 * @param size the number of elements in the existing vector (number 1401 * @param len the number of elements in the existing vector (number
1399 * of elements to copy over), will be updated with the new 1402 * of elements to copy over), will be updated with the new
1400 * array size 1403 * array length
1401 * @param element the element that will be appended to the array 1404 * @param element the element that will be appended to the array
1402 */ 1405 */
1403#define GNUNET_array_append(arr, size, element) \ 1406#define GNUNET_array_append(arr, len, element) \
1407 do \
1408 { \
1409 GNUNET_assert ((len) + 1 > (len)); \
1410 GNUNET_array_grow (arr, len, len + 1); \
1411 (arr) [len - 1] = element; \
1412 } while (0)
1413
1414
1415/**
1416 * @ingroup memory
1417 * Append @a arr2 to @a arr1 (growing @a arr1
1418 * as needed). The @a arr2 array is left unchanged. Naturally
1419 * this function performs a shallow copy. Both arrays must have
1420 * the same type for their elements.
1421 *
1422 * @param arr1 base-pointer of the vector, may be NULL if @a len is 0;
1423 * will be updated to reflect the new address. The TYPE of
1424 * arr is important since size is the number of elements and
1425 * not the size in bytes
1426 * @param len1 the number of elements in the existing vector (number
1427 * of elements to copy over), will be updated with the new
1428 * array size
1429 * @param arr2 base-pointer a second array to concatenate, may be NULL if @a len2 is 0;
1430 * will be updated to reflect the new address. The TYPE of
1431 * arr is important since size is the number of elements and
1432 * not the size in bytes
1433 * @param len the number of elements in the existing vector (number
1434 * of elements to copy over), will be updated with the new
1435 * array size
1436
1437 */
1438#define GNUNET_array_concatenate(arr1, len1, arr2, len2) \
1404 do \ 1439 do \
1405 { \ 1440 { \
1406 GNUNET_array_grow (arr, size, size + 1); \ 1441 const typeof (*arr2) * _a1 = (arr1); \
1407 (arr) [size - 1] = element; \ 1442 const typeof (*arr1) * _a2 = (arr2); \
1443 GNUNET_assert ((len1) + (len2) >= (len1)); \
1444 GNUNET_assert (SIZE_MAX / sizeof (*_a1) >= ((len1) + (len2))); \
1445 GNUNET_array_grow (arr1, len1, (len1) + (len2)); \
1446 memcpy (&(arr1) [(len1) - (len2)], _a2, (len2) * sizeof (*arr1)); \
1408 } while (0) 1447 } while (0)
1409 1448
1410/** 1449/**
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h
index 82b8502e0..27996f18d 100644
--- a/src/include/gnunet_json_lib.h
+++ b/src/include/gnunet_json_lib.h
@@ -219,13 +219,25 @@ GNUNET_JSON_spec_json (const char *name, json_t **jsonp);
219 219
220 220
221/** 221/**
222 * boolean.
223 *
224 * @param name name of the JSON field
225 * @param[out] b where to store the boolean found under @a name
226 */
227struct GNUNET_JSON_Specification
228GNUNET_JSON_spec_bool (const char *name,
229 bool *b);
230
231
232/**
222 * 8-bit integer. 233 * 8-bit integer.
223 * 234 *
224 * @param name name of the JSON field 235 * @param name name of the JSON field
225 * @param[out] u8 where to store the integer found under @a name 236 * @param[out] u8 where to store the integer found under @a name
226 */ 237 */
227struct GNUNET_JSON_Specification 238struct GNUNET_JSON_Specification
228GNUNET_JSON_spec_uint8 (const char *name, uint8_t *u8); 239GNUNET_JSON_spec_uint8 (const char *name,
240 uint8_t *u8);
229 241
230 242
231/** 243/**
@@ -235,7 +247,8 @@ GNUNET_JSON_spec_uint8 (const char *name, uint8_t *u8);
235 * @param[out] u16 where to store the integer found under @a name 247 * @param[out] u16 where to store the integer found under @a name
236 */ 248 */
237struct GNUNET_JSON_Specification 249struct GNUNET_JSON_Specification
238GNUNET_JSON_spec_uint16 (const char *name, uint16_t *u16); 250GNUNET_JSON_spec_uint16 (const char *name,
251 uint16_t *u16);
239 252
240 253
241/** 254/**
@@ -245,7 +258,8 @@ GNUNET_JSON_spec_uint16 (const char *name, uint16_t *u16);
245 * @param[out] u32 where to store the integer found under @a name 258 * @param[out] u32 where to store the integer found under @a name
246 */ 259 */
247struct GNUNET_JSON_Specification 260struct GNUNET_JSON_Specification
248GNUNET_JSON_spec_uint32 (const char *name, uint32_t *u32); 261GNUNET_JSON_spec_uint32 (const char *name,
262 uint32_t *u32);
249 263
250 264
251/** 265/**
@@ -255,7 +269,19 @@ GNUNET_JSON_spec_uint32 (const char *name, uint32_t *u32);
255 * @param[out] u64 where to store the integer found under @a name 269 * @param[out] u64 where to store the integer found under @a name
256 */ 270 */
257struct GNUNET_JSON_Specification 271struct GNUNET_JSON_Specification
258GNUNET_JSON_spec_uint64 (const char *name, uint64_t *u64); 272GNUNET_JSON_spec_uint64 (const char *name,
273 uint64_t *u64);
274
275
276/**
277 * 64-bit signed integer.
278 *
279 * @param name name of the JSON field
280 * @param[out] i64 where to store the integer found under @a name
281 */
282struct GNUNET_JSON_Specification
283GNUNET_JSON_spec_int64 (const char *name,
284 int64_t *i64);
259 285
260 286
261/** 287/**
diff --git a/src/json/Makefile.am b/src/json/Makefile.am
index 5968a3596..9cd80851c 100644
--- a/src/json/Makefile.am
+++ b/src/json/Makefile.am
@@ -37,6 +37,7 @@ TESTS = \
37 37
38test_json_SOURCES = \ 38test_json_SOURCES = \
39 test_json.c 39 test_json.c
40test_json_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
40test_json_LDADD = \ 41test_json_LDADD = \
41 libgnunetjson.la \ 42 libgnunetjson.la \
42 $(top_builddir)/src/util/libgnunetutil.la \ 43 $(top_builddir)/src/util/libgnunetutil.la \
diff --git a/src/json/json_gnsrecord.c b/src/json/json_gnsrecord.c
index bfbdd96ee..37f0c03da 100644
--- a/src/json/json_gnsrecord.c
+++ b/src/json/json_gnsrecord.c
@@ -50,10 +50,10 @@ cleanup_recordinfo (struct GnsRecordInfo *gnsrecord_info)
50{ 50{
51 if (NULL != *(gnsrecord_info->rd)) 51 if (NULL != *(gnsrecord_info->rd))
52 { 52 {
53 for (int i = 0; i < *(gnsrecord_info->rd_count); i++) 53 for (unsigned int i = 0; i < *(gnsrecord_info->rd_count); i++)
54 { 54 {
55 if (NULL != (*(gnsrecord_info->rd))[i].data) 55 if (NULL != (*(gnsrecord_info->rd))[i].data)
56 GNUNET_free ((char *) (*(gnsrecord_info->rd))[i].data); 56 GNUNET_free_nz ((char *) (*(gnsrecord_info->rd))[i].data);
57 } 57 }
58 GNUNET_free (*(gnsrecord_info->rd)); 58 GNUNET_free (*(gnsrecord_info->rd));
59 *(gnsrecord_info->rd) = NULL; 59 *(gnsrecord_info->rd) = NULL;
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index a405b8c3b..02bd6bfab 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -327,6 +327,60 @@ GNUNET_JSON_spec_json (const char *name,
327 327
328 328
329/** 329/**
330 * Parse given JSON object to a bool.
331 *
332 * @param cls closure, NULL
333 * @param root the json object representing data
334 * @param[out] spec where to write the data
335 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
336 */
337static int
338parse_bool (void *cls,
339 json_t *root,
340 struct GNUNET_JSON_Specification *spec)
341{
342 bool *b = spec->ptr;
343
344 if (json_true () == root)
345 {
346 *b = true;
347 return GNUNET_OK;
348 }
349 if (json_false () == root)
350 {
351 *b = false;
352 return GNUNET_OK;
353 }
354 GNUNET_break_op (0);
355 return GNUNET_SYSERR;
356}
357
358
359/**
360 * boolean.
361 *
362 * @param name name of the JSON field
363 * @param[out] b where to store the boolean found under @a name
364 */
365struct GNUNET_JSON_Specification
366GNUNET_JSON_spec_bool (const char *name,
367 bool *b)
368{
369 struct GNUNET_JSON_Specification ret = {
370 .parser = &parse_bool,
371 .cleaner = NULL,
372 .cls = NULL,
373 .field = name,
374 .ptr = b,
375 .ptr_size = sizeof(bool),
376 .size_ptr = NULL
377 };
378
379 return ret;
380}
381
382
383/**
330 * Parse given JSON object to a uint8_t. 384 * Parse given JSON object to a uint8_t.
331 * 385 *
332 * @param cls closure, NULL 386 * @param cls closure, NULL
@@ -495,7 +549,7 @@ GNUNET_JSON_spec_uint32 (const char *name,
495 549
496 550
497/** 551/**
498 * Parse given JSON object to a uint8_t. 552 * Parse given JSON object to a uint64_t.
499 * 553 *
500 * @param cls closure, NULL 554 * @param cls closure, NULL
501 * @param root the json object representing data 555 * @param root the json object representing data
@@ -545,6 +599,57 @@ GNUNET_JSON_spec_uint64 (const char *name,
545} 599}
546 600
547 601
602/**
603 * Parse given JSON object to a int64_t.
604 *
605 * @param cls closure, NULL
606 * @param root the json object representing data
607 * @param[out] spec where to write the data
608 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
609 */
610static int
611parse_i64 (void *cls,
612 json_t *root,
613 struct GNUNET_JSON_Specification *spec)
614{
615 json_int_t val;
616 int64_t *up = spec->ptr;
617
618 if (! json_is_integer (root))
619 {
620 GNUNET_break_op (0);
621 return GNUNET_SYSERR;
622 }
623 val = json_integer_value (root);
624 *up = (int64_t) val;
625 return GNUNET_OK;
626}
627
628
629/**
630 * 64-bit signed integer.
631 *
632 * @param name name of the JSON field
633 * @param[out] i64 where to store the integer found under @a name
634 */
635struct GNUNET_JSON_Specification
636GNUNET_JSON_spec_int64 (const char *name,
637 int64_t *i64)
638{
639 struct GNUNET_JSON_Specification ret = {
640 .parser = &parse_i64,
641 .cleaner = NULL,
642 .cls = NULL,
643 .field = name,
644 .ptr = i64,
645 .ptr_size = sizeof(int64_t),
646 .size_ptr = NULL
647 };
648
649 return ret;
650}
651
652
548/* ************ GNUnet-specific parser specifications ******************* */ 653/* ************ GNUnet-specific parser specifications ******************* */
549 654
550/** 655/**
diff --git a/src/json/test_json_mhd.c b/src/json/test_json_mhd.c
index 5ab1b63ca..642715f25 100644
--- a/src/json/test_json_mhd.c
+++ b/src/json/test_json_mhd.c
@@ -27,6 +27,7 @@
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_json_lib.h" 28#include "gnunet_json_lib.h"
29#include "gnunet_curl_lib.h" 29#include "gnunet_curl_lib.h"
30#include "gnunet_mhd_compat.h"
30#include <zlib.h> 31#include <zlib.h>
31 32
32#define MAX_SIZE 1024 * 1024 33#define MAX_SIZE 1024 * 1024
@@ -36,7 +37,7 @@ static json_t *bigj;
36static int global_ret; 37static int global_ret;
37 38
38 39
39static int 40static MHD_RESULT
40access_handler_cb (void *cls, 41access_handler_cb (void *cls,
41 struct MHD_Connection *connection, 42 struct MHD_Connection *connection,
42 const char *url, 43 const char *url,
diff --git a/src/namecache/gnunet-namecache.c b/src/namecache/gnunet-namecache.c
index 15a0c96ee..2e3c733e6 100644
--- a/src/namecache/gnunet-namecache.c
+++ b/src/namecache/gnunet-namecache.c
@@ -235,10 +235,10 @@ main (int argc, char *const *argv)
235 &run, 235 &run,
236 NULL)) 236 NULL))
237 { 237 {
238 GNUNET_free ((void *) argv); 238 GNUNET_free_nz ((void *) argv);
239 return 1; 239 return 1;
240 } 240 }
241 GNUNET_free ((void *) argv); 241 GNUNET_free_nz ((void *) argv);
242 return ret; 242 return ret;
243} 243}
244 244
diff --git a/src/namecache/test_namecache_api_cache_block.c b/src/namecache/test_namecache_api_cache_block.c
index 9b150c9d9..12b72d93b 100644
--- a/src/namecache/test_namecache_api_cache_block.c
+++ b/src/namecache/test_namecache_api_cache_block.c
@@ -39,7 +39,7 @@ static struct GNUNET_NAMECACHE_Handle *nsh;
39 39
40static struct GNUNET_SCHEDULER_Task *endbadly_task; 40static struct GNUNET_SCHEDULER_Task *endbadly_task;
41 41
42static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; 42static struct GNUNET_CRYPTO_EcdsaPrivateKey privkey;
43 43
44static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; 44static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
45 45
@@ -56,11 +56,6 @@ cleanup ()
56 GNUNET_NAMECACHE_disconnect (nsh); 56 GNUNET_NAMECACHE_disconnect (nsh);
57 nsh = NULL; 57 nsh = NULL;
58 } 58 }
59 if (NULL != privkey)
60 {
61 GNUNET_free (privkey);
62 privkey = NULL;
63 }
64 GNUNET_SCHEDULER_shutdown (); 59 GNUNET_SCHEDULER_shutdown ();
65} 60}
66 61
@@ -188,10 +183,12 @@ run (void *cls,
188 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); 183 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", 184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
190 hostkey_file); 185 hostkey_file);
191 privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); 186 GNUNET_assert (GNUNET_SYSERR !=
187 GNUNET_CRYPTO_ecdsa_key_from_file (hostkey_file,
188 GNUNET_YES,
189 &privkey));
192 GNUNET_free (hostkey_file); 190 GNUNET_free (hostkey_file);
193 GNUNET_assert (privkey != NULL); 191 GNUNET_CRYPTO_ecdsa_key_get_public (&privkey, &pubkey);
194 GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
195 192
196 193
197 rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us + 10000000000; 194 rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us + 10000000000;
@@ -200,7 +197,7 @@ run (void *cls,
200 rd.data = GNUNET_malloc (TEST_RECORD_DATALEN); 197 rd.data = GNUNET_malloc (TEST_RECORD_DATALEN);
201 rd.flags = 0; 198 rd.flags = 0;
202 memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN); 199 memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN);
203 block = GNUNET_GNSRECORD_block_create (privkey, 200 block = GNUNET_GNSRECORD_block_create (&privkey,
204 GNUNET_TIME_UNIT_FOREVER_ABS, 201 GNUNET_TIME_UNIT_FOREVER_ABS,
205 name, &rd, 1); 202 name, &rd, 1);
206 if (NULL == block) 203 if (NULL == block)
@@ -232,7 +229,7 @@ run (void *cls,
232 _ ("Namecache cannot cache no block\n")); 229 _ ("Namecache cannot cache no block\n"));
233 } 230 }
234 GNUNET_free (block); 231 GNUNET_free (block);
235 GNUNET_free ((void *) rd.data); 232 GNUNET_free_nz ((void *) rd.data);
236} 233}
237 234
238 235
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c
index 67fc5bdf4..34641d22e 100644
--- a/src/namestore/gnunet-namestore-fcfsd.c
+++ b/src/namestore/gnunet-namestore-fcfsd.c
@@ -1210,7 +1210,7 @@ main (int argc,
1210 "GNU Name System First Come First Serve name registration service"), 1210 "GNU Name System First Come First Serve name registration service"),
1211 options, 1211 options,
1212 &run, NULL)) ? 0 : 1; 1212 &run, NULL)) ? 0 : 1;
1213 GNUNET_free ((void *) argv); 1213 GNUNET_free_nz ((void *) argv);
1214 GNUNET_CRYPTO_ecdsa_key_clear (&fcfs_zone_pkey); 1214 GNUNET_CRYPTO_ecdsa_key_clear (&fcfs_zone_pkey);
1215 return ret; 1215 return ret;
1216} 1216}
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 25dfda59b..508566a49 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1688,11 +1688,11 @@ main (int argc, char *const *argv)
1688 &run, 1688 &run,
1689 NULL))) 1689 NULL)))
1690 { 1690 {
1691 GNUNET_free ((void *) argv); 1691 GNUNET_free_nz ((void *) argv);
1692 GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); 1692 GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1693 return lret; 1693 return lret;
1694 } 1694 }
1695 GNUNET_free ((void *) argv); 1695 GNUNET_free_nz ((void *) argv);
1696 GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey); 1696 GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1697 return ret; 1697 return ret;
1698} 1698}
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c
index eca02bdc3..5b4e41475 100644
--- a/src/namestore/gnunet-zoneimport.c
+++ b/src/namestore/gnunet-zoneimport.c
@@ -1866,7 +1866,7 @@ main (int argc, char *const *argv)
1866 &run, 1866 &run,
1867 NULL))) 1867 NULL)))
1868 return ret; 1868 return ret;
1869 GNUNET_free ((void *) argv); 1869 GNUNET_free_nz ((void *) argv);
1870 fprintf (stderr, 1870 fprintf (stderr,
1871 "Rejected %u names, had %u cached, did %u lookups, stored %u record sets\n" 1871 "Rejected %u names, had %u cached, did %u lookups, stored %u record sets\n"
1872 "Found %u records, %u lookups failed, %u/%u pending on shutdown\n", 1872 "Found %u records, %u lookups failed, %u/%u pending on shutdown\n",
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c
index d2a93a286..c0bf4b048 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/namestore/plugin_rest_namestore.c
@@ -267,7 +267,7 @@ cleanup_handle (void *cls)
267 for (int i = 0; i < handle->rd_count; i++) 267 for (int i = 0; i < handle->rd_count; i++)
268 { 268 {
269 if (NULL != handle->rd[i].data) 269 if (NULL != handle->rd[i].data)
270 GNUNET_free ((void *) handle->rd[i].data); 270 GNUNET_free_nz ((void *) handle->rd[i].data);
271 } 271 }
272 GNUNET_free (handle->rd); 272 GNUNET_free (handle->rd);
273 } 273 }
diff --git a/src/namestore/test_namestore_api_lookup_private.c b/src/namestore/test_namestore_api_lookup_private.c
index 98fdb1b43..d0ad726cc 100644
--- a/src/namestore/test_namestore_api_lookup_private.c
+++ b/src/namestore/test_namestore_api_lookup_private.c
@@ -212,7 +212,7 @@ run (void *cls,
212 _ ("Namestore cannot store no block\n")); 212 _ ("Namestore cannot store no block\n"));
213 } 213 }
214 214
215 GNUNET_free ((void *) rd.data); 215 GNUNET_free_nz ((void *) rd.data);
216} 216}
217 217
218 218
diff --git a/src/namestore/test_namestore_api_lookup_public.c b/src/namestore/test_namestore_api_lookup_public.c
index 83a5a78f6..039c7cbf6 100644
--- a/src/namestore/test_namestore_api_lookup_public.c
+++ b/src/namestore/test_namestore_api_lookup_public.c
@@ -221,7 +221,7 @@ run (void *cls,
221 _ ("Namestore cannot store no block\n")); 221 _ ("Namestore cannot store no block\n"));
222 } 222 }
223 223
224 GNUNET_free ((void *) rd.data); 224 GNUNET_free_nz ((void *) rd.data);
225} 225}
226 226
227 227
diff --git a/src/namestore/test_namestore_api_lookup_shadow.c b/src/namestore/test_namestore_api_lookup_shadow.c
index 08c428731..d399d903a 100644
--- a/src/namestore/test_namestore_api_lookup_shadow.c
+++ b/src/namestore/test_namestore_api_lookup_shadow.c
@@ -254,7 +254,7 @@ run (void *cls,
254 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 254 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
255 _ ("Namestore cannot store no block\n")); 255 _ ("Namestore cannot store no block\n"));
256 } 256 }
257 GNUNET_free ((void *) rd.data); 257 GNUNET_free_nz ((void *) rd.data);
258} 258}
259 259
260 260
diff --git a/src/namestore/test_namestore_api_lookup_shadow_filter.c b/src/namestore/test_namestore_api_lookup_shadow_filter.c
index 634a6a3c4..40dbeb90f 100644
--- a/src/namestore/test_namestore_api_lookup_shadow_filter.c
+++ b/src/namestore/test_namestore_api_lookup_shadow_filter.c
@@ -336,8 +336,8 @@ run (void *cls,
336 _ ("Namestore cannot store no block\n")); 336 _ ("Namestore cannot store no block\n"));
337 } 337 }
338 338
339 GNUNET_free ((void *) records[0].data); 339 GNUNET_free_nz ((void *) records[0].data);
340 GNUNET_free ((void *) records[1].data); 340 GNUNET_free_nz ((void *) records[1].data);
341} 341}
342 342
343 343
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c
index d26492517..cc00adf44 100644
--- a/src/namestore/test_namestore_api_monitoring.c
+++ b/src/namestore/test_namestore_api_monitoring.c
@@ -94,17 +94,17 @@ do_shutdown ()
94 94
95 if (s_rd_1 != NULL) 95 if (s_rd_1 != NULL)
96 { 96 {
97 GNUNET_free ((void *) s_rd_1->data); 97 GNUNET_free_nz ((void *) s_rd_1->data);
98 GNUNET_free (s_rd_1); 98 GNUNET_free (s_rd_1);
99 } 99 }
100 if (s_rd_2 != NULL) 100 if (s_rd_2 != NULL)
101 { 101 {
102 GNUNET_free ((void *) s_rd_2->data); 102 GNUNET_free_nz ((void *) s_rd_2->data);
103 GNUNET_free (s_rd_2); 103 GNUNET_free (s_rd_2);
104 } 104 }
105 if (s_rd_3 != NULL) 105 if (s_rd_3 != NULL)
106 { 106 {
107 GNUNET_free ((void *) s_rd_3->data); 107 GNUNET_free_nz ((void *) s_rd_3->data);
108 GNUNET_free (s_rd_3); 108 GNUNET_free (s_rd_3);
109 } 109 }
110} 110}
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c
index 040a63f91..728fcc25e 100644
--- a/src/namestore/test_namestore_api_monitoring_existing.c
+++ b/src/namestore/test_namestore_api_monitoring_existing.c
@@ -111,17 +111,17 @@ end (void *cls)
111 } 111 }
112 if (NULL != s_rd_1) 112 if (NULL != s_rd_1)
113 { 113 {
114 GNUNET_free ((void *) s_rd_1->data); 114 GNUNET_free_nz ((void *) s_rd_1->data);
115 GNUNET_free (s_rd_1); 115 GNUNET_free (s_rd_1);
116 } 116 }
117 if (NULL != s_rd_2) 117 if (NULL != s_rd_2)
118 { 118 {
119 GNUNET_free ((void *) s_rd_2->data); 119 GNUNET_free_nz ((void *) s_rd_2->data);
120 GNUNET_free (s_rd_2); 120 GNUNET_free (s_rd_2);
121 } 121 }
122 if (NULL != s_rd_3) 122 if (NULL != s_rd_3)
123 { 123 {
124 GNUNET_free ((void *) s_rd_3->data); 124 GNUNET_free_nz ((void *) s_rd_3->data);
125 GNUNET_free (s_rd_3); 125 GNUNET_free (s_rd_3);
126 } 126 }
127} 127}
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c
index 3f0c4c123..e575821e8 100644
--- a/src/namestore/test_namestore_api_remove.c
+++ b/src/namestore/test_namestore_api_remove.c
@@ -187,7 +187,7 @@ run (void *cls,
187 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 187 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
188 _ ("Namestore cannot store no block\n")); 188 _ ("Namestore cannot store no block\n"));
189 } 189 }
190 GNUNET_free ((void *) rd.data); 190 GNUNET_free_nz ((void *) rd.data);
191} 191}
192 192
193 193
diff --git a/src/namestore/test_namestore_api_store.c b/src/namestore/test_namestore_api_store.c
index ab211aeae..9223b56a3 100644
--- a/src/namestore/test_namestore_api_store.c
+++ b/src/namestore/test_namestore_api_store.c
@@ -138,7 +138,7 @@ run (void *cls,
138 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 138 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
139 _ ("Namestore cannot store no block\n")); 139 _ ("Namestore cannot store no block\n"));
140 } 140 }
141 GNUNET_free ((void *) rd.data); 141 GNUNET_free_nz ((void *) rd.data);
142} 142}
143 143
144 144
diff --git a/src/namestore/test_namestore_api_store_update.c b/src/namestore/test_namestore_api_store_update.c
index 65dbdbd8c..7a5a69a6c 100644
--- a/src/namestore/test_namestore_api_store_update.c
+++ b/src/namestore/test_namestore_api_store_update.c
@@ -274,7 +274,7 @@ run (void *cls,
274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
275 _ ("Namestore cannot store no block\n")); 275 _ ("Namestore cannot store no block\n"));
276 } 276 }
277 GNUNET_free ((void *) rd.data); 277 GNUNET_free_nz ((void *) rd.data);
278} 278}
279 279
280 280
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c
index d69b7cc62..a363ee28d 100644
--- a/src/namestore/test_namestore_api_zone_iteration.c
+++ b/src/namestore/test_namestore_api_zone_iteration.c
@@ -37,9 +37,9 @@ static struct GNUNET_NAMESTORE_Handle *nsh;
37 37
38static struct GNUNET_SCHEDULER_Task *endbadly_task; 38static struct GNUNET_SCHEDULER_Task *endbadly_task;
39 39
40static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; 40static struct GNUNET_CRYPTO_EcdsaPrivateKey privkey;
41 41
42static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey2; 42static struct GNUNET_CRYPTO_EcdsaPrivateKey privkey2;
43 43
44static struct GNUNET_NAMESTORE_ZoneIterator *zi; 44static struct GNUNET_NAMESTORE_ZoneIterator *zi;
45 45
@@ -88,32 +88,22 @@ end (void *cls)
88 GNUNET_SCHEDULER_cancel (endbadly_task); 88 GNUNET_SCHEDULER_cancel (endbadly_task);
89 endbadly_task = NULL; 89 endbadly_task = NULL;
90 } 90 }
91 if (NULL != privkey)
92 {
93 GNUNET_free (privkey);
94 privkey = NULL;
95 }
96 if (NULL != privkey2)
97 {
98 GNUNET_free (privkey2);
99 privkey2 = NULL;
100 }
101 GNUNET_free_non_null (s_name_1); 91 GNUNET_free_non_null (s_name_1);
102 GNUNET_free_non_null (s_name_2); 92 GNUNET_free_non_null (s_name_2);
103 GNUNET_free_non_null (s_name_3); 93 GNUNET_free_non_null (s_name_3);
104 if (NULL != s_rd_1) 94 if (NULL != s_rd_1)
105 { 95 {
106 GNUNET_free ((void *) s_rd_1->data); 96 GNUNET_free_nz ((void *) s_rd_1->data);
107 GNUNET_free (s_rd_1); 97 GNUNET_free (s_rd_1);
108 } 98 }
109 if (NULL != s_rd_2) 99 if (NULL != s_rd_2)
110 { 100 {
111 GNUNET_free ((void *) s_rd_2->data); 101 GNUNET_free_nz ((void *) s_rd_2->data);
112 GNUNET_free (s_rd_2); 102 GNUNET_free (s_rd_2);
113 } 103 }
114 if (NULL != s_rd_3) 104 if (NULL != s_rd_3)
115 { 105 {
116 GNUNET_free ((void *) s_rd_3->data); 106 GNUNET_free_nz ((void *) s_rd_3->data);
117 GNUNET_free (s_rd_3); 107 GNUNET_free (s_rd_3);
118 } 108 }
119 if (NULL != nsh) 109 if (NULL != nsh)
@@ -161,7 +151,7 @@ zone_proc (void *cls,
161 151
162 GNUNET_assert (NULL != zone); 152 GNUNET_assert (NULL != zone);
163 if (0 == GNUNET_memcmp (zone, 153 if (0 == GNUNET_memcmp (zone,
164 privkey)) 154 &privkey))
165 { 155 {
166 if (0 == strcmp (label, s_name_1)) 156 if (0 == strcmp (label, s_name_1))
167 { 157 {
@@ -207,7 +197,7 @@ zone_proc (void *cls,
207 } 197 }
208 } 198 }
209 else if (0 == GNUNET_memcmp (zone, 199 else if (0 == GNUNET_memcmp (zone,
210 privkey2)) 200 &privkey2))
211 { 201 {
212 if (0 == strcmp (label, s_name_3)) 202 if (0 == strcmp (label, s_name_3))
213 { 203 {
@@ -382,9 +372,11 @@ empty_zone_end (void *cls)
382 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 372 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
383 "Using zonekey file `%s' \n", 373 "Using zonekey file `%s' \n",
384 hostkey_file); 374 hostkey_file);
385 privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); 375 GNUNET_assert (GNUNET_SYSERR !=
376 GNUNET_CRYPTO_ecdsa_key_from_file (hostkey_file,
377 GNUNET_YES,
378 &privkey));
386 GNUNET_free (hostkey_file); 379 GNUNET_free (hostkey_file);
387 GNUNET_assert (privkey != NULL);
388 380
389 GNUNET_asprintf (&hostkey_file, 381 GNUNET_asprintf (&hostkey_file,
390 "zonefiles%s%s", 382 "zonefiles%s%s",
@@ -393,16 +385,18 @@ empty_zone_end (void *cls)
393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
394 "Using zonekey file `%s' \n", 386 "Using zonekey file `%s' \n",
395 hostkey_file); 387 hostkey_file);
396 privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); 388 GNUNET_assert (GNUNET_SYSERR !=
389 GNUNET_CRYPTO_ecdsa_key_from_file (hostkey_file,
390 GNUNET_YES,
391 &privkey2));
397 GNUNET_free (hostkey_file); 392 GNUNET_free (hostkey_file);
398 GNUNET_assert (privkey2 != NULL);
399 393
400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); 394 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n");
401 395
402 GNUNET_asprintf (&s_name_1, "dummy1"); 396 GNUNET_asprintf (&s_name_1, "dummy1");
403 s_rd_1 = create_record (1); 397 s_rd_1 = create_record (1);
404 GNUNET_NAMESTORE_records_store (nsh, 398 GNUNET_NAMESTORE_records_store (nsh,
405 privkey, 399 &privkey,
406 s_name_1, 400 s_name_1,
407 1, s_rd_1, 401 1, s_rd_1,
408 &put_cont, 402 &put_cont,
@@ -412,7 +406,7 @@ empty_zone_end (void *cls)
412 GNUNET_asprintf (&s_name_2, "dummy2"); 406 GNUNET_asprintf (&s_name_2, "dummy2");
413 s_rd_2 = create_record (1); 407 s_rd_2 = create_record (1);
414 GNUNET_NAMESTORE_records_store (nsh, 408 GNUNET_NAMESTORE_records_store (nsh,
415 privkey, 409 &privkey,
416 s_name_2, 410 s_name_2,
417 1, s_rd_2, 411 1, s_rd_2,
418 &put_cont, 412 &put_cont,
@@ -423,7 +417,7 @@ empty_zone_end (void *cls)
423 GNUNET_asprintf (&s_name_3, "dummy3"); 417 GNUNET_asprintf (&s_name_3, "dummy3");
424 s_rd_3 = create_record (1); 418 s_rd_3 = create_record (1);
425 GNUNET_NAMESTORE_records_store (nsh, 419 GNUNET_NAMESTORE_records_store (nsh,
426 privkey2, 420 &privkey2,
427 s_name_3, 421 s_name_3,
428 1, 422 1,
429 s_rd_3, 423 s_rd_3,
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c
index f5ffe3899..b0c4c8211 100644
--- a/src/namestore/test_namestore_api_zone_iteration_nick.c
+++ b/src/namestore/test_namestore_api_zone_iteration_nick.c
@@ -87,17 +87,17 @@ end (void *cls)
87 87
88 if (s_rd_1 != NULL) 88 if (s_rd_1 != NULL)
89 { 89 {
90 GNUNET_free ((void *) s_rd_1->data); 90 GNUNET_free_nz ((void *) s_rd_1->data);
91 GNUNET_free (s_rd_1); 91 GNUNET_free (s_rd_1);
92 } 92 }
93 if (s_rd_2 != NULL) 93 if (s_rd_2 != NULL)
94 { 94 {
95 GNUNET_free ((void *) s_rd_2->data); 95 GNUNET_free_nz ((void *) s_rd_2->data);
96 GNUNET_free (s_rd_2); 96 GNUNET_free (s_rd_2);
97 } 97 }
98 if (s_rd_3 != NULL) 98 if (s_rd_3 != NULL)
99 { 99 {
100 GNUNET_free ((void *) s_rd_3->data); 100 GNUNET_free_nz ((void *) s_rd_3->data);
101 GNUNET_free (s_rd_3); 101 GNUNET_free (s_rd_3);
102 } 102 }
103} 103}
diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
index 97093cb71..0534da001 100644
--- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
+++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
@@ -93,17 +93,17 @@ end (void *cls)
93 GNUNET_free_non_null (s_name_3); 93 GNUNET_free_non_null (s_name_3);
94 if (s_rd_1 != NULL) 94 if (s_rd_1 != NULL)
95 { 95 {
96 GNUNET_free ((void *) s_rd_1->data); 96 GNUNET_free_nz ((void *) s_rd_1->data);
97 GNUNET_free (s_rd_1); 97 GNUNET_free (s_rd_1);
98 } 98 }
99 if (s_rd_2 != NULL) 99 if (s_rd_2 != NULL)
100 { 100 {
101 GNUNET_free ((void *) s_rd_2->data); 101 GNUNET_free_nz ((void *) s_rd_2->data);
102 GNUNET_free (s_rd_2); 102 GNUNET_free (s_rd_2);
103 } 103 }
104 if (s_rd_3 != NULL) 104 if (s_rd_3 != NULL)
105 { 105 {
106 GNUNET_free ((void *) s_rd_3->data); 106 GNUNET_free_nz ((void *) s_rd_3->data);
107 GNUNET_free (s_rd_3); 107 GNUNET_free (s_rd_3);
108 } 108 }
109 if (nsh != NULL) 109 if (nsh != NULL)
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c
index 81fb4de7e..b71a8789c 100644
--- a/src/namestore/test_namestore_api_zone_iteration_stop.c
+++ b/src/namestore/test_namestore_api_zone_iteration_stop.c
@@ -34,9 +34,9 @@
34 34
35static struct GNUNET_NAMESTORE_Handle *nsh; 35static struct GNUNET_NAMESTORE_Handle *nsh;
36 36
37static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; 37static struct GNUNET_CRYPTO_EcdsaPrivateKey privkey;
38 38
39static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey2; 39static struct GNUNET_CRYPTO_EcdsaPrivateKey privkey2;
40 40
41static struct GNUNET_NAMESTORE_ZoneIterator *zi; 41static struct GNUNET_NAMESTORE_ZoneIterator *zi;
42 42
@@ -80,29 +80,19 @@ end (void *cls)
80 GNUNET_free_non_null (s_name_3); 80 GNUNET_free_non_null (s_name_3);
81 if (s_rd_1 != NULL) 81 if (s_rd_1 != NULL)
82 { 82 {
83 GNUNET_free ((void *) s_rd_1->data); 83 GNUNET_free_nz ((void *) s_rd_1->data);
84 GNUNET_free (s_rd_1); 84 GNUNET_free (s_rd_1);
85 } 85 }
86 if (s_rd_2 != NULL) 86 if (s_rd_2 != NULL)
87 { 87 {
88 GNUNET_free ((void *) s_rd_2->data); 88 GNUNET_free_nz ((void *) s_rd_2->data);
89 GNUNET_free (s_rd_2); 89 GNUNET_free (s_rd_2);
90 } 90 }
91 if (s_rd_3 != NULL) 91 if (s_rd_3 != NULL)
92 { 92 {
93 GNUNET_free ((void *) s_rd_3->data); 93 GNUNET_free_nz ((void *) s_rd_3->data);
94 GNUNET_free (s_rd_3); 94 GNUNET_free (s_rd_3);
95 } 95 }
96 if (privkey != NULL)
97 {
98 GNUNET_free (privkey);
99 privkey = NULL;
100 }
101 if (privkey2 != NULL)
102 {
103 GNUNET_free (privkey2);
104 privkey2 = NULL;
105 }
106} 96}
107 97
108 98
@@ -130,7 +120,7 @@ zone_proc (void *cls,
130 int failed = GNUNET_NO; 120 int failed = GNUNET_NO;
131 121
132 GNUNET_assert (NULL != zone); 122 GNUNET_assert (NULL != zone);
133 if (0 == GNUNET_memcmp (zone, privkey)) 123 if (0 == GNUNET_memcmp (zone, &privkey))
134 { 124 {
135 if (0 == strcmp (label, s_name_1)) 125 if (0 == strcmp (label, s_name_1))
136 { 126 {
@@ -175,7 +165,7 @@ zone_proc (void *cls,
175 GNUNET_break (0); 165 GNUNET_break (0);
176 } 166 }
177 } 167 }
178 else if (0 == GNUNET_memcmp (zone, privkey2)) 168 else if (0 == GNUNET_memcmp (zone, &privkey2))
179 { 169 {
180 if (0 == strcmp (label, s_name_3)) 170 if (0 == strcmp (label, s_name_3))
181 { 171 {
@@ -368,10 +358,11 @@ empty_zone_proc_end (void *cls)
368 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
369 "Using zonekey file `%s' \n", 359 "Using zonekey file `%s' \n",
370 hostkey_file); 360 hostkey_file);
371 privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); 361 GNUNET_assert (GNUNET_SYSERR
362 != GNUNET_CRYPTO_ecdsa_key_from_file (hostkey_file,
363 GNUNET_YES,
364 &privkey));
372 GNUNET_free (hostkey_file); 365 GNUNET_free (hostkey_file);
373 GNUNET_assert (privkey != NULL);
374
375 GNUNET_asprintf (&hostkey_file, 366 GNUNET_asprintf (&hostkey_file,
376 "zonefiles%s%s", 367 "zonefiles%s%s",
377 DIR_SEPARATOR_STR, 368 DIR_SEPARATOR_STR,
@@ -379,17 +370,19 @@ empty_zone_proc_end (void *cls)
379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
380 "Using zonekey file `%s'\n", 371 "Using zonekey file `%s'\n",
381 hostkey_file); 372 hostkey_file);
382 privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); 373 GNUNET_assert (GNUNET_SYSERR !=
374 GNUNET_CRYPTO_ecdsa_key_from_file (hostkey_file,
375 GNUNET_YES,
376 &privkey2));
383 GNUNET_free (hostkey_file); 377 GNUNET_free (hostkey_file);
384 GNUNET_assert (privkey2 != NULL);
385
386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
387 "Created record 1\n"); 379 "Created record 1\n");
388 380
389 GNUNET_asprintf (&s_name_1, 381 GNUNET_asprintf (&s_name_1,
390 "dummy1"); 382 "dummy1");
391 s_rd_1 = create_record (1); 383 s_rd_1 = create_record (1);
392 GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_1, 384 GNUNET_NAMESTORE_records_store (nsh,
385 &privkey, s_name_1,
393 1, s_rd_1, &put_cont, NULL); 386 1, s_rd_1, &put_cont, NULL);
394 387
395 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 388 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -398,7 +391,7 @@ empty_zone_proc_end (void *cls)
398 "dummy2"); 391 "dummy2");
399 s_rd_2 = create_record (1); 392 s_rd_2 = create_record (1);
400 GNUNET_NAMESTORE_records_store (nsh, 393 GNUNET_NAMESTORE_records_store (nsh,
401 privkey, 394 &privkey,
402 s_name_2, 395 s_name_2,
403 1, 396 1,
404 s_rd_2, 397 s_rd_2,
@@ -411,7 +404,7 @@ empty_zone_proc_end (void *cls)
411 GNUNET_asprintf (&s_name_3, "dummy3"); 404 GNUNET_asprintf (&s_name_3, "dummy3");
412 s_rd_3 = create_record (1); 405 s_rd_3 = create_record (1);
413 GNUNET_NAMESTORE_records_store (nsh, 406 GNUNET_NAMESTORE_records_store (nsh,
414 privkey2, 407 &privkey2,
415 s_name_3, 408 s_name_3,
416 1, 409 1,
417 s_rd_3, 410 s_rd_3,
diff --git a/src/nat-auto/gnunet-nat-auto.c b/src/nat-auto/gnunet-nat-auto.c
index d40f4ef32..95a7ced9e 100644
--- a/src/nat-auto/gnunet-nat-auto.c
+++ b/src/nat-auto/gnunet-nat-auto.c
@@ -359,7 +359,7 @@ main (int argc, char *const argv[])
359 { 359 {
360 global_ret = 1; 360 global_ret = 1;
361 } 361 }
362 GNUNET_free ((void *) argv); 362 GNUNET_free_nz ((void *) argv);
363 return global_ret; 363 return global_ret;
364} 364}
365 365
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c
index 857ce5093..5012d6455 100644
--- a/src/nat/gnunet-nat.c
+++ b/src/nat/gnunet-nat.c
@@ -468,7 +468,7 @@ main (int argc, char *const argv[])
468 { 468 {
469 global_ret = 1; 469 global_ret = 1;
470 } 470 }
471 GNUNET_free ((void *) argv); 471 GNUNET_free_nz ((void *) argv);
472 return global_ret; 472 return global_ret;
473} 473}
474 474
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index 4d4c4de33..df6c169b5 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -855,7 +855,7 @@ main (int argc, char *const *argv)
855 NULL)) 855 NULL))
856 ? 0 856 ? 0
857 : 1; 857 : 1;
858 GNUNET_free ((void *) argv); 858 GNUNET_free_nz ((void *) argv);
859 return ret; 859 return ret;
860} 860}
861 861
diff --git a/src/peerinfo-tool/plugin_rest_peerinfo.c b/src/peerinfo-tool/plugin_rest_peerinfo.c
index 14559a8cf..6e156569a 100644
--- a/src/peerinfo-tool/plugin_rest_peerinfo.c
+++ b/src/peerinfo-tool/plugin_rest_peerinfo.c
@@ -272,7 +272,7 @@ cleanup_handle (void *cls)
272 if (NULL != handle->emsg) 272 if (NULL != handle->emsg)
273 GNUNET_free (handle->emsg); 273 GNUNET_free (handle->emsg);
274 if (NULL != handle->address) 274 if (NULL != handle->address)
275 GNUNET_free ((char *) handle->address); 275 GNUNET_free_nz ((char *) handle->address);
276 if (NULL != handle->expiration_str) 276 if (NULL != handle->expiration_str)
277 GNUNET_free (handle->expiration_str); 277 GNUNET_free (handle->expiration_str);
278 if (NULL != handle->pubkey) 278 if (NULL != handle->pubkey)
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c
index f8765818b..bcc913bd2 100644
--- a/src/pt/gnunet-daemon-pt.c
+++ b/src/pt/gnunet-daemon-pt.c
@@ -1317,7 +1317,7 @@ main (int argc,
1317 NULL)) 1317 NULL))
1318 ? 0 1318 ? 0
1319 : 1; 1319 : 1;
1320 GNUNET_free ((void *) argv); 1320 GNUNET_free_nz ((void *) argv);
1321 return ret; 1321 return ret;
1322} 1322}
1323 1323
diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c
index 9bf497b16..69afca789 100644
--- a/src/pt/test_gns_vpn.c
+++ b/src/pt/test_gns_vpn.c
@@ -45,6 +45,7 @@
45#include "gnunet_gnsrecord_lib.h" 45#include "gnunet_gnsrecord_lib.h"
46#include "gnunet_gns_service.h" 46#include "gnunet_gns_service.h"
47#include "gnunet_testing_lib.h" 47#include "gnunet_testing_lib.h"
48#include "gnunet_mhd_compat.h"
48 49
49#define PORT 8080 50#define PORT 8080
50#define TEST_DOMAIN "www.gnu" 51#define TEST_DOMAIN "www.gnu"
@@ -121,7 +122,7 @@ copy_buffer (void *ptr,
121} 122}
122 123
123 124
124static int 125static MHD_RESULT
125mhd_ahc (void *cls, 126mhd_ahc (void *cls,
126 struct MHD_Connection *connection, 127 struct MHD_Connection *connection,
127 const char *url, 128 const char *url,
@@ -611,7 +612,7 @@ identity_cb (void *cls,
611 1, &rd, 612 1, &rd,
612 &commence_testing, 613 &commence_testing,
613 NULL); 614 NULL);
614 GNUNET_free ((void **) rd.data); 615 GNUNET_free_nz ((void **) rd.data);
615 GNUNET_free (rd_string); 616 GNUNET_free (rd_string);
616} 617}
617 618
diff --git a/src/pt/test_gnunet_vpn.c b/src/pt/test_gnunet_vpn.c
index 42fd52c38..cb9bb61fe 100644
--- a/src/pt/test_gnunet_vpn.c
+++ b/src/pt/test_gnunet_vpn.c
@@ -29,6 +29,7 @@
29#include <microhttpd.h> 29#include <microhttpd.h>
30#include "gnunet_vpn_service.h" 30#include "gnunet_vpn_service.h"
31#include "gnunet_testing_lib.h" 31#include "gnunet_testing_lib.h"
32#include "gnunet_mhd_compat.h"
32 33
33#define PORT 48080 34#define PORT 48080
34 35
@@ -96,7 +97,7 @@ copy_buffer (void *ptr, size_t size, size_t nmemb, void *ctx)
96} 97}
97 98
98 99
99static int 100static MHD_RESULT
100mhd_ahc (void *cls, 101mhd_ahc (void *cls,
101 struct MHD_Connection *connection, 102 struct MHD_Connection *connection,
102 const char *url, 103 const char *url,
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c
index eda58fdd2..d94b5ae46 100644
--- a/src/regex/gnunet-daemon-regexprofiler.c
+++ b/src/regex/gnunet-daemon-regexprofiler.c
@@ -118,7 +118,7 @@ shutdown_task (void *cls)
118 } 118 }
119 if (NULL != reannounce_task) 119 if (NULL != reannounce_task)
120 { 120 {
121 GNUNET_free (GNUNET_SCHEDULER_cancel (reannounce_task)); 121 GNUNET_free_nz (GNUNET_SCHEDULER_cancel (reannounce_task));
122 reannounce_task = NULL; 122 reannounce_task = NULL;
123 } 123 }
124 if (NULL != dht_handle) 124 if (NULL != dht_handle)
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c
index 19fd5ab2c..8b7cf33c6 100644
--- a/src/revocation/gnunet-revocation.c
+++ b/src/revocation/gnunet-revocation.c
@@ -555,7 +555,7 @@ main (int argc, char *const *argv)
555 NULL)) 555 NULL))
556 ? ret 556 ? ret
557 : 1; 557 : 1;
558 GNUNET_free ((void *) argv); 558 GNUNET_free_nz ((void *) argv);
559 return ret; 559 return ret;
560} 560}
561 561
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index 47bdbf2c1..63afde877 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -881,7 +881,7 @@ main (int argc, char *const *argv)
881 num_nodes, 881 num_nodes,
882 0); 882 0);
883 GNUNET_free_non_null (remote_host); 883 GNUNET_free_non_null (remote_host);
884 GNUNET_free ((void *) argv); 884 GNUNET_free_nz ((void *) argv);
885 return ret; 885 return ret;
886} 886}
887 887
diff --git a/src/template/gnunet-template.c b/src/template/gnunet-template.c
index b33cbcc64..5e250bbdf 100644
--- a/src/template/gnunet-template.c
+++ b/src/template/gnunet-template.c
@@ -78,7 +78,7 @@ main (int argc, char *const *argv)
78 NULL)) 78 NULL))
79 ? ret 79 ? ret
80 : 1; 80 : 1;
81 GNUNET_free ((void *) argv); 81 GNUNET_free_nz ((void *) argv);
82 return ret; 82 return ret;
83} 83}
84 84
diff --git a/src/testbed/gnunet-daemon-latency-logger.c b/src/testbed/gnunet-daemon-latency-logger.c
index 0af718a63..c13750db7 100644
--- a/src/testbed/gnunet-daemon-latency-logger.c
+++ b/src/testbed/gnunet-daemon-latency-logger.c
@@ -317,6 +317,6 @@ main (int argc, char *const *argv)
317 _ ( 317 _ (
318 "Daemon to log latency values of connections to neighbours"), 318 "Daemon to log latency values of connections to neighbours"),
319 options, &run, NULL)) ? 0 : 1; 319 options, &run, NULL)) ? 0 : 1;
320 GNUNET_free ((void *) argv); 320 GNUNET_free_nz ((void *) argv);
321 return ret; 321 return ret;
322} 322}
diff --git a/src/testbed/gnunet-daemon-testbed-blacklist.c b/src/testbed/gnunet-daemon-testbed-blacklist.c
index 070583941..c82f8075f 100644
--- a/src/testbed/gnunet-daemon-testbed-blacklist.c
+++ b/src/testbed/gnunet-daemon-testbed-blacklist.c
@@ -249,6 +249,6 @@ main (int argc, char *const *argv)
249 _ ( 249 _ (
250 "Daemon to restrict incoming transport layer connections during testbed deployments"), 250 "Daemon to restrict incoming transport layer connections during testbed deployments"),
251 options, &run, NULL)) ? 0 : 1; 251 options, &run, NULL)) ? 0 : 1;
252 GNUNET_free ((void *) argv); 252 GNUNET_free_nz ((void *) argv);
253 return ret; 253 return ret;
254} 254}
diff --git a/src/testbed/gnunet-daemon-testbed-underlay.c b/src/testbed/gnunet-daemon-testbed-underlay.c
index 09dfee5a6..2bff7cdd4 100644
--- a/src/testbed/gnunet-daemon-testbed-underlay.c
+++ b/src/testbed/gnunet-daemon-testbed-underlay.c
@@ -476,6 +476,6 @@ main (int argc, char *const *argv)
476 ( 476 (
477 "Daemon to restrict underlay network in testbed deployments"), 477 "Daemon to restrict underlay network in testbed deployments"),
478 options, &run, NULL)) ? 0 : 1; 478 options, &run, NULL)) ? 0 : 1;
479 GNUNET_free ((void *) argv); 479 GNUNET_free_nz ((void *) argv);
480 return ret; 480 return ret;
481} 481}
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c
index cfc6367fe..90813c8e5 100644
--- a/src/testbed/gnunet-testbed-profiler.c
+++ b/src/testbed/gnunet-testbed-profiler.c
@@ -318,7 +318,7 @@ main (int argc, char *const *argv)
318 ret = 318 ret =
319 GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-profiler", binaryHelp, 319 GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-profiler", binaryHelp,
320 options, &run, NULL); 320 options, &run, NULL);
321 GNUNET_free ((void *) argv); 321 GNUNET_free_nz ((void *) argv);
322 if (GNUNET_OK != ret) 322 if (GNUNET_OK != ret)
323 return ret; 323 return ret;
324 if (GNUNET_OK != result) 324 if (GNUNET_OK != result)
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c
index b850d6b13..a9e5042b2 100644
--- a/src/testing/gnunet-testing.c
+++ b/src/testing/gnunet-testing.c
@@ -436,7 +436,7 @@ main (int argc, char *const *argv)
436 GNUNET_YES)) 436 GNUNET_YES))
437 ? ret 437 ? ret
438 : 1; 438 : 1;
439 GNUNET_free ((void *) argv); 439 GNUNET_free_nz ((void *) argv);
440 return ret; 440 return ret;
441} 441}
442 442
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 3e447e1ff..23bc40d7e 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -1343,7 +1343,7 @@ GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
1343 return; 1343 return;
1344 } 1344 }
1345 peer->id = GNUNET_new (struct GNUNET_PeerIdentity); 1345 peer->id = GNUNET_new (struct GNUNET_PeerIdentity);
1346 GNUNET_free ( 1346 GNUNET_free_nz (
1347 GNUNET_TESTING_hostkey_get (peer->system, peer->key_number, peer->id)); 1347 GNUNET_TESTING_hostkey_get (peer->system, peer->key_number, peer->id));
1348 GNUNET_memcpy (id, peer->id, sizeof(struct GNUNET_PeerIdentity)); 1348 GNUNET_memcpy (id, peer->id, sizeof(struct GNUNET_PeerIdentity));
1349} 1349}
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index 261d825ea..c6f600df1 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -1130,7 +1130,7 @@ main (int argc, char *const *argv)
1130 NULL)) 1130 NULL))
1131 ? 0 1131 ? 0
1132 : 1; 1132 : 1;
1133 GNUNET_free ((void *) argv); 1133 GNUNET_free_nz ((void *) argv);
1134 return ret; 1134 return ret;
1135} 1135}
1136 1136
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 82ee309a5..bbfacbffd 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -2285,7 +2285,7 @@ main (int argc, char *const *argv)
2285 NULL)) 2285 NULL))
2286 ? 0 2286 ? 0
2287 : 1; 2287 : 1;
2288 GNUNET_free ((void *) argv); 2288 GNUNET_free_nz ((void *) argv);
2289 return ret; 2289 return ret;
2290} 2290}
2291 2291
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index e0b14f669..72e84567a 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -2791,7 +2791,7 @@ main (int argc, char *const *argv)
2791 NULL)) 2791 NULL))
2792 ? 0 2792 ? 0
2793 : 1; 2793 : 1;
2794 GNUNET_free ((void *) argv); 2794 GNUNET_free_nz ((void *) argv);
2795 return ret; 2795 return ret;
2796} 2796}
2797 2797
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c
index 7d7f18a9c..31d2e4ed3 100644
--- a/src/transport/gnunet-communicator-unix.c
+++ b/src/transport/gnunet-communicator-unix.c
@@ -1135,7 +1135,7 @@ main (int argc, char *const *argv)
1135 NULL)) 1135 NULL))
1136 ? 0 1136 ? 0
1137 : 1; 1137 : 1;
1138 GNUNET_free ((void *) argv); 1138 GNUNET_free_nz ((void *) argv);
1139 return ret; 1139 return ret;
1140} 1140}
1141 1141
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c
index 6c13cf059..81678fa20 100644
--- a/src/transport/gnunet-transport-profiler.c
+++ b/src/transport/gnunet-transport-profiler.c
@@ -615,7 +615,7 @@ main (int argc, char *const *argv)
615 options, 615 options,
616 &run, 616 &run,
617 NULL); 617 NULL);
618 GNUNET_free ((void *) argv); 618 GNUNET_free_nz ((void *) argv);
619 if (GNUNET_OK == res) 619 if (GNUNET_OK == res)
620 return ret; 620 return ret;
621 return 1; 621 return 1;
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 5a437b660..35da5ec10 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -1427,7 +1427,7 @@ main (int argc, char *const *argv)
1427 options, 1427 options,
1428 &run, 1428 &run,
1429 NULL); 1429 NULL);
1430 GNUNET_free ((void *) argv); 1430 GNUNET_free_nz ((void *) argv);
1431 if (GNUNET_OK == res) 1431 if (GNUNET_OK == res)
1432 return ret; 1432 return ret;
1433 return 1; 1433 return 1;
diff --git a/src/transport/tcp_service_legacy.c b/src/transport/tcp_service_legacy.c
index f207863f9..fb4e9c3c9 100644
--- a/src/transport/tcp_service_legacy.c
+++ b/src/transport/tcp_service_legacy.c
@@ -1474,7 +1474,7 @@ shutdown:
1474 i = 0; 1474 i = 0;
1475 if (NULL != sctx.addrs) 1475 if (NULL != sctx.addrs)
1476 while (NULL != sctx.addrs[i]) 1476 while (NULL != sctx.addrs[i])
1477 GNUNET_free (sctx.addrs[i++]); 1477 GNUNET_free_nz (sctx.addrs[i++]);
1478 GNUNET_free_non_null (sctx.addrs); 1478 GNUNET_free_non_null (sctx.addrs);
1479 GNUNET_free_non_null (sctx.addrlens); 1479 GNUNET_free_non_null (sctx.addrlens);
1480 GNUNET_free_non_null (logfile); 1480 GNUNET_free_non_null (logfile);
@@ -1631,7 +1631,7 @@ LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *sctx)
1631 { 1631 {
1632 i = 0; 1632 i = 0;
1633 while (NULL != sctx->addrs[i]) 1633 while (NULL != sctx->addrs[i])
1634 GNUNET_free (sctx->addrs[i++]); 1634 GNUNET_free_nz (sctx->addrs[i++]);
1635 GNUNET_free (sctx->addrs); 1635 GNUNET_free (sctx->addrs);
1636 } 1636 }
1637 GNUNET_free_non_null (sctx->addrlens); 1637 GNUNET_free_non_null (sctx->addrlens);
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index 10e07dae5..04687d845 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -49,7 +49,7 @@ static struct GNUNET_PeerIdentity my_identity;
49/** 49/**
50 * Our private key. 50 * Our private key.
51 */ 51 */
52static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; 52static struct GNUNET_CRYPTO_EddsaPrivateKey my_private_key;
53 53
54/** 54/**
55 * Our configuration. 55 * Our configuration.
@@ -647,16 +647,20 @@ run (void *cls,
647 } 647 }
648 648
649 max_connect_per_transport = (uint32_t) tneigh; 649 max_connect_per_transport = (uint32_t) tneigh;
650 my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); 650 if (GNUNET_SYSERR ==
651 GNUNET_free (keyfile); 651 GNUNET_CRYPTO_eddsa_key_from_file (keyfile,
652 if (NULL == my_private_key) 652 GNUNET_YES,
653 &my_private_key))
653 { 654 {
655 GNUNET_free (keyfile);
654 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 656 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
655 "Could not access hostkey. Exiting.\n"); 657 "Could not access hostkey. Exiting.\n");
656 end_badly_now (); 658 end_badly_now ();
657 return; 659 return;
658 } 660 }
659 GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, &my_identity.public_key); 661 GNUNET_free (keyfile);
662 GNUNET_CRYPTO_eddsa_key_get_public (&my_private_key,
663 &my_identity.public_key);
660 664
661 hello = GNUNET_HELLO_create (&my_identity.public_key, NULL, NULL, GNUNET_NO); 665 hello = GNUNET_HELLO_create (&my_identity.public_key, NULL, NULL, GNUNET_NO);
662 666
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index f101e8b61..5883c1497 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -331,7 +331,7 @@ main (int argc, char *const *argv)
331 options, 331 options,
332 &run, 332 &run,
333 NULL); 333 NULL);
334 GNUNET_free ((void *) argv); 334 GNUNET_free_nz ((void *) argv);
335 if (GNUNET_OK == ret) 335 if (GNUNET_OK == ret)
336 return global_ret; 336 return global_ret;
337 return ret; 337 return ret;
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c
index 764a507b6..8e30ac416 100644
--- a/src/util/gnunet-ecc.c
+++ b/src/util/gnunet-ecc.c
@@ -501,7 +501,7 @@ main (int argc, char *const *argv)
501 NULL)) 501 NULL))
502 ? 0 502 ? 0
503 : 1; 503 : 1;
504 GNUNET_free ((void *) argv); 504 GNUNET_free_nz ((void *) argv);
505 return ret; 505 return ret;
506} 506}
507 507
diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c
index 6a602c64e..8a6c7fbe9 100644
--- a/src/util/gnunet-resolver.c
+++ b/src/util/gnunet-resolver.c
@@ -171,14 +171,18 @@ main (int argc, char *const *argv)
171 }; 171 };
172 int ret; 172 int ret;
173 173
174 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 174 if (GNUNET_OK !=
175 GNUNET_STRINGS_get_utf8_args (argc, argv,
176 &argc, &argv))
175 return 2; 177 return 2;
176 178
177 ret = (GNUNET_OK == 179 ret = (GNUNET_OK ==
178 GNUNET_PROGRAM_run (argc, argv, "gnunet-resolver [hostname]", 180 GNUNET_PROGRAM_run (argc, argv,
181 "gnunet-resolver [hostname]",
179 gettext_noop ("Use build-in GNUnet stub resolver"), 182 gettext_noop ("Use build-in GNUnet stub resolver"),
180 options, &run, NULL)) ? 0 : 1; 183 options,
181 GNUNET_free ((void *) argv); 184 &run, NULL)) ? 0 : 1;
185 GNUNET_free_nz ((void *) argv);
182 return ret; 186 return ret;
183} 187}
184 188
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c
index 8c46136b9..70ba48d82 100644
--- a/src/util/gnunet-scrypt.c
+++ b/src/util/gnunet-scrypt.c
@@ -322,7 +322,7 @@ main (int argc, char *const *argv)
322 NULL)) 322 NULL))
323 ? 0 323 ? 0
324 : 1; 324 : 1;
325 GNUNET_free ((void *) argv); 325 GNUNET_free_nz ((void *) argv);
326 GNUNET_free_non_null (pwfn); 326 GNUNET_free_non_null (pwfn);
327 return ret; 327 return ret;
328} 328}
diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c
index 84100ff56..48c46ee49 100644
--- a/src/util/gnunet-uri.c
+++ b/src/util/gnunet-uri.c
@@ -184,7 +184,7 @@ main (int argc, char *const *argv)
184 shc_chld = NULL; 184 shc_chld = NULL;
185 GNUNET_DISK_pipe_close (sigpipe); 185 GNUNET_DISK_pipe_close (sigpipe);
186 sigpipe = NULL; 186 sigpipe = NULL;
187 GNUNET_free ((void *) argv); 187 GNUNET_free_nz ((void *) argv);
188 return ((GNUNET_OK == ret) && (0 == exit_code)) ? 0 : 1; 188 return ((GNUNET_OK == ret) && (0 == exit_code)) ? 0 : 1;
189} 189}
190 190
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index 36f0d8e30..5799d893b 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -875,7 +875,7 @@ GNUNET_OS_start_process_s (int pipe_control,
875 binary_path, 875 binary_path,
876 argv); 876 argv);
877 while (argv_size > 0) 877 while (argv_size > 0)
878 GNUNET_free (argv[--argv_size]); 878 GNUNET_free_nz (argv[--argv_size]);
879 GNUNET_free (argv); 879 GNUNET_free (argv);
880 return proc; 880 return proc;
881} 881}
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 45a6b61e5..93393bd7c 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -584,28 +584,26 @@ dump_backtrace (struct GNUNET_SCHEDULER_Task *t)
584static void 584static void
585destroy_task (struct GNUNET_SCHEDULER_Task *t) 585destroy_task (struct GNUNET_SCHEDULER_Task *t)
586{ 586{
587 unsigned int i;
588
589 LOG (GNUNET_ERROR_TYPE_DEBUG, 587 LOG (GNUNET_ERROR_TYPE_DEBUG,
590 "destroying task %p\n", 588 "destroying task %p\n",
591 t); 589 t);
592 590
593 if (GNUNET_YES == t->own_handles) 591 if (GNUNET_YES == t->own_handles)
594 { 592 {
595 for (i = 0; i != t->fds_len; ++i) 593 for (unsigned int i = 0; i != t->fds_len; ++i)
596 { 594 {
597 const struct GNUNET_NETWORK_Handle *fd = t->fds[i].fd; 595 const struct GNUNET_NETWORK_Handle *fd = t->fds[i].fd;
598 const struct GNUNET_DISK_FileHandle *fh = t->fds[i].fh; 596 const struct GNUNET_DISK_FileHandle *fh = t->fds[i].fh;
599 if (fd) 597 if (fd)
600 { 598 {
601 GNUNET_NETWORK_socket_free_memory_only_ ((struct 599 GNUNET_NETWORK_socket_free_memory_only_ (
602 GNUNET_NETWORK_Handle *) fd); 600 (struct GNUNET_NETWORK_Handle *) fd);
603 } 601 }
604 if (fh) 602 if (fh)
605 { 603 {
606 // FIXME: on WIN32 this is not enough! A function 604 // FIXME: on WIN32 this is not enough! A function
607 // GNUNET_DISK_file_free_memory_only would be nice 605 // GNUNET_DISK_file_free_memory_only would be nice
608 GNUNET_free ((void *) fh); 606 GNUNET_free_nz ((void *) fh);
609 } 607 }
610 } 608 }
611 } 609 }
diff --git a/src/util/test_common_allocation.c b/src/util/test_common_allocation.c
index e2fc29e82..a24af7124 100644
--- a/src/util/test_common_allocation.c
+++ b/src/util/test_common_allocation.c
@@ -27,7 +27,7 @@
27 27
28 28
29static int 29static int
30check () 30check (void)
31{ 31{
32#define MAX_TESTVAL 1024 32#define MAX_TESTVAL 1024
33 char *ptrs[MAX_TESTVAL]; 33 char *ptrs[MAX_TESTVAL];
@@ -134,6 +134,28 @@ check ()
134} 134}
135 135
136 136
137static int
138check2 (void)
139{
140 char *a1 = NULL;
141 unsigned int a1_len = 0;
142 const char *a2 = "test";
143
144 GNUNET_array_append (a1,
145 a1_len,
146 'x');
147 GNUNET_array_concatenate (a1,
148 a1_len,
149 a2,
150 4);
151 GNUNET_assert (0 == strncmp ("xtest",
152 a1,
153 5));
154 GNUNET_assert (5 == a1_len);
155 return 0;
156}
157
158
137int 159int
138main (int argc, char *argv[]) 160main (int argc, char *argv[])
139{ 161{
@@ -142,7 +164,7 @@ main (int argc, char *argv[])
142 GNUNET_log_setup ("test-common-allocation", 164 GNUNET_log_setup ("test-common-allocation",
143 "WARNING", 165 "WARNING",
144 NULL); 166 NULL);
145 ret = check (); 167 ret = check () | check2 ();
146 if (ret != 0) 168 if (ret != 0)
147 fprintf (stderr, 169 fprintf (stderr,
148 "ERROR %d.\n", 170 "ERROR %d.\n",
diff --git a/src/vpn/gnunet-vpn.c b/src/vpn/gnunet-vpn.c
index 6dcd227c7..a7f7fc30c 100644
--- a/src/vpn/gnunet-vpn.c
+++ b/src/vpn/gnunet-vpn.c
@@ -357,7 +357,7 @@ main (int argc, char *const *argv)
357 NULL)) 357 NULL))
358 ? ret 358 ? ret
359 : 1; 359 : 1;
360 GNUNET_free ((void *) argv); 360 GNUNET_free_nz ((void *) argv);
361 return ret; 361 return ret;
362} 362}
363 363