aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2017-12-02 22:34:21 +0100
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2017-12-02 22:34:21 +0100
commitb16fa2d88aabb18f222b40136d6ace68ffc104c6 (patch)
tree6d46f086f018b6e6c169a8d8312b5990c33c3561 /src
parenta9a7ac802811e76e33b54040bf31f00ea9438cea (diff)
parent862e488e08ca71db56dedd59059c5bb1a8c130a5 (diff)
downloadgnunet-b16fa2d88aabb18f222b40136d6ace68ffc104c6.tar.gz
gnunet-b16fa2d88aabb18f222b40136d6ace68ffc104c6.zip
Merge remote-tracking branch 'origin/master' into identity_abe
Diffstat (limited to 'src')
-rw-r--r--src/arm/Makefile.am3
-rw-r--r--src/ats-tool/gnunet-ats.c6
-rw-r--r--src/cadet/gnunet-service-cadet_paths.c6
-rw-r--r--src/conversation/gnunet-conversation.c2
-rw-r--r--src/core/gnunet-service-core_sessions.c1
-rw-r--r--src/core/test_core_api_reliability.c3
-rw-r--r--src/datastore/datastore_api.c115
-rw-r--r--src/dht/Makefile.am3
-rw-r--r--src/dns/dnsparser.c4
-rw-r--r--src/fs/fs_misc.c8
-rw-r--r--src/fs/fs_publish_ublock.c1
-rw-r--r--src/include/gnunet_crypto_lib.h20
-rw-r--r--src/include/gnunet_getopt_lib.h54
-rw-r--r--src/include/gnunet_json_lib.h10
-rw-r--r--src/include/gnunet_scheduler_lib.h16
-rw-r--r--src/integration-tests/Makefile.am3
-rw-r--r--src/json/json_generator.c13
-rw-r--r--src/revocation/gnunet-service-revocation.c2
-rw-r--r--src/secretsharing/Makefile.am2
-rw-r--r--src/social/gnunet-social.c2
-rw-r--r--src/social/social_api.c2
-rw-r--r--src/sq/sq_result_helper.c2
-rw-r--r--src/statistics/Makefile.am3
-rw-r--r--src/testbed/testbed_api_topology.c2
-rw-r--r--src/topology/friends.c2
-rw-r--r--src/transport/gnunet-service-transport.c10
-rw-r--r--src/transport/gnunet-service-transport_ats.c3
-rw-r--r--src/transport/gnunet-service-transport_validation.c21
-rw-r--r--src/transport/test_transport_testing_restart.c3
-rw-r--r--src/transport/test_transport_testing_startstop.c3
-rw-r--r--src/transport/transport-testing.c7
-rw-r--r--src/util/crypto_ecc.c45
-rw-r--r--src/util/crypto_paillier.c2
-rw-r--r--src/util/crypto_rsa.c2
-rw-r--r--src/util/gnunet-ecc.c22
-rw-r--r--src/util/resolver_api.c1
-rw-r--r--src/util/scheduler.c48
-rw-r--r--src/util/test_crypto_paillier.c35
-rw-r--r--src/util/test_mq.c1
39 files changed, 322 insertions, 166 deletions
diff --git a/src/arm/Makefile.am b/src/arm/Makefile.am
index 373847fde..b1706a479 100644
--- a/src/arm/Makefile.am
+++ b/src/arm/Makefile.am
@@ -92,7 +92,8 @@ test_gnunet_service_arm_SOURCES = \
92 92
93do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' 93do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g'
94 94
95%.py: %.py.in Makefile 95SUFFIXES = .py.in .py
96.py.in.py:
96 $(do_subst) < $(srcdir)/$< > $@ 97 $(do_subst) < $(srcdir)/$< > $@
97 chmod +x $@ 98 chmod +x $@
98 99
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c
index 5ec7693b1..d88e6d523 100644
--- a/src/ats-tool/gnunet-ats.c
+++ b/src/ats-tool/gnunet-ats.c
@@ -872,8 +872,8 @@ run (void *cls,
872 872
873 for (c = 0; c < strlen (opt_type_str); c++) 873 for (c = 0; c < strlen (opt_type_str); c++)
874 { 874 {
875 if (isupper (opt_type_str[c])) 875 if (isupper ((unsigned char) opt_type_str[c]))
876 opt_type_str[c] = tolower (opt_type_str[c]); 876 opt_type_str[c] = tolower ((unsigned char) opt_type_str[c]);
877 } 877 }
878 878
879 if (0 == strcasecmp ("latency", opt_type_str)) 879 if (0 == strcasecmp ("latency", opt_type_str))
@@ -974,7 +974,7 @@ main (int argc,
974 gettext_noop ("set preference for the given peer"), 974 gettext_noop ("set preference for the given peer"),
975 &opt_set_pref), 975 &opt_set_pref),
976 976
977 GNUNET_GETOPT_option_flag ('q', 977 GNUNET_GETOPT_option_flag ('q',
978 "quotas", 978 "quotas",
979 gettext_noop ("print all configured quotas"), 979 gettext_noop ("print all configured quotas"),
980 &opt_print_quotas), 980 &opt_print_quotas),
diff --git a/src/cadet/gnunet-service-cadet_paths.c b/src/cadet/gnunet-service-cadet_paths.c
index 13752643c..79eed0dcc 100644
--- a/src/cadet/gnunet-service-cadet_paths.c
+++ b/src/cadet/gnunet-service-cadet_paths.c
@@ -179,7 +179,7 @@ GCPP_del_connection (struct CadetPeerPath *path,
179 GCC_2s (cc), 179 GCC_2s (cc),
180 GCPP_2s (path), 180 GCPP_2s (path),
181 off); 181 off);
182 GNUNET_assert (off < path->entries_length); 182 GNUNET_assert (off < path->entries_length); /* FIXME: This assertion fails sometimes! */
183 entry = path->entries[off]; 183 entry = path->entries[off];
184 GNUNET_assert (cc == entry->cc); 184 GNUNET_assert (cc == entry->cc);
185 entry->cc = NULL; 185 entry->cc = NULL;
@@ -498,8 +498,8 @@ GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path,
498 const struct GNUNET_PeerIdentity *pid; 498 const struct GNUNET_PeerIdentity *pid;
499 499
500 pid = (off < get_path_length) 500 pid = (off < get_path_length)
501 ? &get_path[get_path_length - off] 501 ? &get_path[get_path_length - off - 1]
502 : &put_path[get_path_length + put_path_length - off]; 502 : &put_path[get_path_length + put_path_length - off - 1];
503 cpath[off - skip] = GCP_get (pid, 503 cpath[off - skip] = GCP_get (pid,
504 GNUNET_YES); 504 GNUNET_YES);
505 /* Check that no peer is twice on the path */ 505 /* Check that no peer is twice on the path */
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c
index 8f9ddec25..00ab65680 100644
--- a/src/conversation/gnunet-conversation.c
+++ b/src/conversation/gnunet-conversation.c
@@ -1091,7 +1091,7 @@ handle_command_string (char *message,
1091 strlen (commands[i].command)))) 1091 strlen (commands[i].command))))
1092 i++; 1092 i++;
1093 ptr = &message[strlen (commands[i].command)]; 1093 ptr = &message[strlen (commands[i].command)];
1094 while (isspace ((int) *ptr)) 1094 while (isspace ((unsigned char) *ptr))
1095 ptr++; 1095 ptr++;
1096 if ('\0' == *ptr) 1096 if ('\0' == *ptr)
1097 ptr = NULL; 1097 ptr = NULL;
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c
index 034f2e883..5d34b7c26 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.c
@@ -975,6 +975,7 @@ GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
975 session = find_session (peer); 975 session = find_session (peer);
976 if (NULL == session) 976 if (NULL == session)
977 { 977 {
978 GSC_TYPEMAP_destroy (nmap);
978 GNUNET_break (0); 979 GNUNET_break (0);
979 return; 980 return;
980 } 981 }
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 900c9f732..528093c99 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -381,6 +381,7 @@ process_hello (void *cls,
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
382 "Received (my) `%s' from transport service\n", "HELLO"); 382 "Received (my) `%s' from transport service\n", "HELLO");
383 GNUNET_assert (message != NULL); 383 GNUNET_assert (message != NULL);
384 GNUNET_free_non_null (p->hello);
384 p->hello = GNUNET_copy_message (message); 385 p->hello = GNUNET_copy_message (message);
385 if ((p == &p1) && (NULL == p2.oh)) 386 if ((p == &p1) && (NULL == p2.oh))
386 p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg, 387 p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg,
@@ -518,6 +519,8 @@ main (int argc,
518 &ok); 519 &ok);
519 stop_arm (&p1); 520 stop_arm (&p1);
520 stop_arm (&p2); 521 stop_arm (&p2);
522 GNUNET_free_non_null (p1.hello);
523 GNUNET_free_non_null (p2.hello);
521 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); 524 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1");
522 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); 525 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2");
523 526
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 31f7a997f..2ad864987 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -651,6 +651,46 @@ process_queue (struct GNUNET_DATASTORE_Handle *h)
651} 651}
652 652
653 653
654/**
655 * Get the entry at the head of the message queue.
656 *
657 * @param h handle to the datastore
658 * @param response_type the expected response type
659 * @return the queue entry
660 */
661static struct GNUNET_DATASTORE_QueueEntry *
662get_queue_head (struct GNUNET_DATASTORE_Handle *h,
663 uint16_t response_type)
664{
665 struct GNUNET_DATASTORE_QueueEntry *qe;
666
667 if (h->skip_next_messages > 0)
668 {
669 h->skip_next_messages--;
670 process_queue (h);
671 return NULL;
672 }
673 qe = h->queue_head;
674 if (NULL == qe)
675 {
676 GNUNET_break (0);
677 do_disconnect (h);
678 return NULL;
679 }
680 if (NULL != qe->env)
681 {
682 GNUNET_break (0);
683 do_disconnect (h);
684 return NULL;
685 }
686 if (response_type != qe->response_type)
687 {
688 GNUNET_break (0);
689 do_disconnect (h);
690 return NULL;
691 }
692 return qe;
693}
654 694
655 695
656/** 696/**
@@ -702,30 +742,10 @@ handle_status (void *cls,
702 const char *emsg; 742 const char *emsg;
703 int32_t status = ntohl (sm->status); 743 int32_t status = ntohl (sm->status);
704 744
705 if (h->skip_next_messages > 0) 745 qe = get_queue_head (h,
706 { 746 GNUNET_MESSAGE_TYPE_DATASTORE_STATUS);
707 h->skip_next_messages--; 747 if (NULL == qe)
708 process_queue (h);
709 return;
710 }
711 if (NULL == (qe = h->queue_head))
712 {
713 GNUNET_break (0);
714 do_disconnect (h);
715 return;
716 }
717 if (NULL != qe->env)
718 {
719 GNUNET_break (0);
720 do_disconnect (h);
721 return;
722 }
723 if (GNUNET_MESSAGE_TYPE_DATASTORE_STATUS != qe->response_type)
724 {
725 GNUNET_break (0);
726 do_disconnect (h);
727 return; 748 return;
728 }
729 rc = qe->qc.sc; 749 rc = qe->qc.sc;
730 free_queue_entry (qe); 750 free_queue_entry (qe);
731 if (ntohs (sm->header.size) > sizeof (struct StatusMessage)) 751 if (ntohs (sm->header.size) > sizeof (struct StatusMessage))
@@ -785,30 +805,10 @@ handle_data (void *cls,
785 struct GNUNET_DATASTORE_QueueEntry *qe; 805 struct GNUNET_DATASTORE_QueueEntry *qe;
786 struct ResultContext rc; 806 struct ResultContext rc;
787 807
788 if (h->skip_next_messages > 0) 808 qe = get_queue_head (h,
789 { 809 GNUNET_MESSAGE_TYPE_DATASTORE_DATA);
790 process_queue (h);
791 return;
792 }
793 qe = h->queue_head;
794 if (NULL == qe) 810 if (NULL == qe)
795 {
796 GNUNET_break (0);
797 do_disconnect (h);
798 return;
799 }
800 if (NULL != qe->env)
801 {
802 GNUNET_break (0);
803 do_disconnect (h);
804 return;
805 }
806 if (GNUNET_MESSAGE_TYPE_DATASTORE_DATA != qe->response_type)
807 {
808 GNUNET_break (0);
809 do_disconnect (h);
810 return; 811 return;
811 }
812#if INSANE_STATISTICS 812#if INSANE_STATISTICS
813 GNUNET_STATISTICS_update (h->stats, 813 GNUNET_STATISTICS_update (h->stats,
814 gettext_noop ("# Results received"), 814 gettext_noop ("# Results received"),
@@ -854,31 +854,10 @@ handle_data_end (void *cls,
854 struct GNUNET_DATASTORE_QueueEntry *qe; 854 struct GNUNET_DATASTORE_QueueEntry *qe;
855 struct ResultContext rc; 855 struct ResultContext rc;
856 856
857 if (h->skip_next_messages > 0) 857 qe = get_queue_head (h,
858 { 858 GNUNET_MESSAGE_TYPE_DATASTORE_DATA);
859 h->skip_next_messages--;
860 process_queue (h);
861 return;
862 }
863 qe = h->queue_head;
864 if (NULL == qe) 859 if (NULL == qe)
865 {
866 GNUNET_break (0);
867 do_disconnect (h);
868 return; 860 return;
869 }
870 if (NULL != qe->env)
871 {
872 GNUNET_break (0);
873 do_disconnect (h);
874 return;
875 }
876 if (GNUNET_MESSAGE_TYPE_DATASTORE_DATA != qe->response_type)
877 {
878 GNUNET_break (0);
879 do_disconnect (h);
880 return;
881 }
882 rc = qe->qc.rc; 861 rc = qe->qc.rc;
883 free_queue_entry (qe); 862 free_queue_entry (qe);
884 LOG (GNUNET_ERROR_TYPE_DEBUG, 863 LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am
index 00ce0e934..4a78ea4c7 100644
--- a/src/dht/Makefile.am
+++ b/src/dht/Makefile.am
@@ -213,7 +213,8 @@ endif
213 213
214do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' -e 's,[@]bindir[@],$(bindir),g' 214do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' -e 's,[@]bindir[@],$(bindir),g'
215 215
216%.py: %.py.in Makefile 216SUFFIXES = .py.in .py
217.py.in.py:
217 $(do_subst) < $(srcdir)/$< > $@ 218 $(do_subst) < $(srcdir)/$< > $@
218 chmod +x $@ 219 chmod +x $@
219 220
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c
index 36b4c36f1..30d9245ff 100644
--- a/src/dns/dnsparser.c
+++ b/src/dns/dnsparser.c
@@ -1278,8 +1278,8 @@ GNUNET_DNSPARSER_hex_to_bin (const char *hex,
1278 in[2] = '\0'; 1278 in[2] = '\0';
1279 for (off = 0; off < data_size; off++) 1279 for (off = 0; off < data_size; off++)
1280 { 1280 {
1281 in[0] = tolower ((int) hex[off * 2]); 1281 in[0] = tolower ((unsigned char) hex[off * 2]);
1282 in[1] = tolower ((int) hex[off * 2 + 1]); 1282 in[1] = tolower ((unsigned char) hex[off * 2 + 1]);
1283 if (1 != sscanf (in, "%x", &h)) 1283 if (1 != sscanf (in, "%x", &h))
1284 return off; 1284 return off;
1285 idata[off] = (uint8_t) h; 1285 idata[off] = (uint8_t) h;
diff --git a/src/fs/fs_misc.c b/src/fs/fs_misc.c
index bcb8620cf..b26de431c 100644
--- a/src/fs/fs_misc.c
+++ b/src/fs/fs_misc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2010, 2011 GNUnet e.V. 3 Copyright (C) 2010, 2011, 2017 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -43,6 +43,8 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
43 {"application/gnunet-directory", ".gnd"}, 43 {"application/gnunet-directory", ".gnd"},
44 {"application/java", ".class"}, 44 {"application/java", ".class"},
45 {"application/msword", ".doc"}, 45 {"application/msword", ".doc"},
46 {"application/nar", ".nar"},
47 {"application/narinfo", ".narinfo"},
46 {"application/ogg", ".ogg"}, 48 {"application/ogg", ".ogg"},
47 {"application/pdf", ".pdf"}, 49 {"application/pdf", ".pdf"},
48 {"application/pgp-keys", ".key"}, 50 {"application/pgp-keys", ".key"},
@@ -53,8 +55,8 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
53 {"application/xml", ".xml"}, 55 {"application/xml", ".xml"},
54 {"application/x-debian-package", ".deb"}, 56 {"application/x-debian-package", ".deb"},
55 {"application/x-dvi", ".dvi"}, 57 {"application/x-dvi", ".dvi"},
56 {"applixation/x-flac", ".flac"}, 58 {"application/x-flac", ".flac"},
57 {"applixation/x-gzip", ".gz"}, 59 {"application/x-gzip", ".gz"},
58 {"application/x-java-archive", ".jar"}, 60 {"application/x-java-archive", ".jar"},
59 {"application/x-java-vm", ".class"}, 61 {"application/x-java-vm", ".class"},
60 {"application/x-python-code", ".pyc"}, 62 {"application/x-python-code", ".pyc"},
diff --git a/src/fs/fs_publish_ublock.c b/src/fs/fs_publish_ublock.c
index e21443ccb..189a6909a 100644
--- a/src/fs/fs_publish_ublock.c
+++ b/src/fs/fs_publish_ublock.c
@@ -301,6 +301,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
301 uc->task = GNUNET_SCHEDULER_add_now (&run_cont, 301 uc->task = GNUNET_SCHEDULER_add_now (&run_cont,
302 uc); 302 uc);
303 } 303 }
304 GNUNET_free (ub_enc);
304 return uc; 305 return uc;
305} 306}
306 307
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 2b6718557..2fd67ae1b 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -1115,6 +1115,16 @@ GNUNET_CRYPTO_ecdsa_public_key_to_string (const struct GNUNET_CRYPTO_EcdsaPublic
1115 1115
1116 1116
1117/** 1117/**
1118 * Convert a private key to a string.
1119 *
1120 * @param priv key to convert
1121 * @return string representing @a pub
1122 */
1123char *
1124GNUNET_CRYPTO_eddsa_private_key_to_string (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1125
1126
1127/**
1118 * Convert a public key to a string. 1128 * Convert a public key to a string.
1119 * 1129 *
1120 * @param pub key to convert 1130 * @param pub key to convert
@@ -2021,13 +2031,14 @@ GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_RsaPublicKey *p1,
2021 * @param pkey the public key of the signer 2031 * @param pkey the public key of the signer
2022 * @param[out] buf set to a buffer with the blinded message to be signed 2032 * @param[out] buf set to a buffer with the blinded message to be signed
2023 * @param[out] buf_size number of bytes stored in @a buf 2033 * @param[out] buf_size number of bytes stored in @a buf
2024 * @return GNUNET_YES if successful, GNUNET_NO if RSA key is malicious 2034 * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious
2025 */ 2035 */
2026int 2036int
2027GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, 2037GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2028 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, 2038 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2029 struct GNUNET_CRYPTO_RsaPublicKey *pkey, 2039 struct GNUNET_CRYPTO_RsaPublicKey *pkey,
2030 char **buf, size_t *buf_size); 2040 char **buf,
2041 size_t *buf_size);
2031 2042
2032 2043
2033/** 2044/**
@@ -2040,7 +2051,8 @@ GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2040 */ 2051 */
2041struct GNUNET_CRYPTO_RsaSignature * 2052struct GNUNET_CRYPTO_RsaSignature *
2042GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, 2053GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2043 const void *msg, size_t msg_len); 2054 const void *msg,
2055 size_t msg_len);
2044 2056
2045 2057
2046/** 2058/**
@@ -2110,7 +2122,7 @@ GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig);
2110 * @return unblinded signature on success, NULL if RSA key is bad or malicious. 2122 * @return unblinded signature on success, NULL if RSA key is bad or malicious.
2111 */ 2123 */
2112struct GNUNET_CRYPTO_RsaSignature * 2124struct GNUNET_CRYPTO_RsaSignature *
2113GNUNET_CRYPTO_rsa_unblind (struct GNUNET_CRYPTO_RsaSignature *sig, 2125GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig,
2114 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, 2126 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2115 struct GNUNET_CRYPTO_RsaPublicKey *pkey); 2127 struct GNUNET_CRYPTO_RsaPublicKey *pkey);
2116 2128
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index f707bb091..e38925f14 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -230,11 +230,11 @@ GNUNET_GETOPT_option_filename (char shortName,
230 */ 230 */
231struct GNUNET_GETOPT_CommandLineOption 231struct GNUNET_GETOPT_CommandLineOption
232GNUNET_GETOPT_option_base32_fixed_size (char shortName, 232GNUNET_GETOPT_option_base32_fixed_size (char shortName,
233 const char *name, 233 const char *name,
234 const char *argumentHelp, 234 const char *argumentHelp,
235 const char *description, 235 const char *description,
236 void *val, 236 void *val,
237 size_t val_size); 237 size_t val_size);
238 238
239 239
240/** 240/**
@@ -264,9 +264,9 @@ GNUNET_GETOPT_option_base32_fixed_size (char shortName,
264 */ 264 */
265struct GNUNET_GETOPT_CommandLineOption 265struct GNUNET_GETOPT_CommandLineOption
266GNUNET_GETOPT_option_flag (char shortName, 266GNUNET_GETOPT_option_flag (char shortName,
267 const char *name, 267 const char *name,
268 const char *description, 268 const char *description,
269 int *val); 269 int *val);
270 270
271 271
272/** 272/**
@@ -280,10 +280,10 @@ GNUNET_GETOPT_option_flag (char shortName,
280 */ 280 */
281struct GNUNET_GETOPT_CommandLineOption 281struct GNUNET_GETOPT_CommandLineOption
282GNUNET_GETOPT_option_uint (char shortName, 282GNUNET_GETOPT_option_uint (char shortName,
283 const char *name, 283 const char *name,
284 const char *argumentHelp, 284 const char *argumentHelp,
285 const char *description, 285 const char *description,
286 unsigned int *val); 286 unsigned int *val);
287 287
288 288
289/** 289/**
@@ -297,10 +297,10 @@ GNUNET_GETOPT_option_uint (char shortName,
297 */ 297 */
298struct GNUNET_GETOPT_CommandLineOption 298struct GNUNET_GETOPT_CommandLineOption
299GNUNET_GETOPT_option_ulong (char shortName, 299GNUNET_GETOPT_option_ulong (char shortName,
300 const char *name, 300 const char *name,
301 const char *argumentHelp, 301 const char *argumentHelp,
302 const char *description, 302 const char *description,
303 unsigned long long *val); 303 unsigned long long *val);
304 304
305 305
306/** 306/**
@@ -315,10 +315,10 @@ GNUNET_GETOPT_option_ulong (char shortName,
315 */ 315 */
316struct GNUNET_GETOPT_CommandLineOption 316struct GNUNET_GETOPT_CommandLineOption
317GNUNET_GETOPT_option_relative_time (char shortName, 317GNUNET_GETOPT_option_relative_time (char shortName,
318 const char *name, 318 const char *name,
319 const char *argumentHelp, 319 const char *argumentHelp,
320 const char *description, 320 const char *description,
321 struct GNUNET_TIME_Relative *val); 321 struct GNUNET_TIME_Relative *val);
322 322
323 323
324/** 324/**
@@ -333,10 +333,10 @@ GNUNET_GETOPT_option_relative_time (char shortName,
333 */ 333 */
334struct GNUNET_GETOPT_CommandLineOption 334struct GNUNET_GETOPT_CommandLineOption
335GNUNET_GETOPT_option_absolute_time (char shortName, 335GNUNET_GETOPT_option_absolute_time (char shortName,
336 const char *name, 336 const char *name,
337 const char *argumentHelp, 337 const char *argumentHelp,
338 const char *description, 338 const char *description,
339 struct GNUNET_TIME_Absolute *val); 339 struct GNUNET_TIME_Absolute *val);
340 340
341 341
342/** 342/**
@@ -350,9 +350,9 @@ GNUNET_GETOPT_option_absolute_time (char shortName,
350 */ 350 */
351struct GNUNET_GETOPT_CommandLineOption 351struct GNUNET_GETOPT_CommandLineOption
352GNUNET_GETOPT_option_increment_uint (char shortName, 352GNUNET_GETOPT_option_increment_uint (char shortName,
353 const char *name, 353 const char *name,
354 const char *description, 354 const char *description,
355 unsigned int *val); 355 unsigned int *val);
356 356
357 357
358/** 358/**
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h
index f2682bea7..c12badcd9 100644
--- a/src/include/gnunet_json_lib.h
+++ b/src/include/gnunet_json_lib.h
@@ -343,6 +343,16 @@ GNUNET_JSON_from_time_abs (struct GNUNET_TIME_Absolute stamp);
343 343
344 344
345/** 345/**
346 * Convert absolute timestamp to a json string.
347 *
348 * @param stamp the time stamp
349 * @return a json string with the timestamp in @a stamp
350 */
351json_t *
352GNUNET_JSON_from_time_abs_nbo (struct GNUNET_TIME_AbsoluteNBO stamp);
353
354
355/**
346 * Convert relative timestamp to a json string. 356 * Convert relative timestamp to a json string.
347 * 357 *
348 * @param stamp the time stamp 358 * @param stamp the time stamp
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h
index 875f5043a..a855ab8ab 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -400,6 +400,22 @@ void
400GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, 400GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task,
401 void *task_cls); 401 void *task_cls);
402 402
403/**
404 * Initialize and run scheduler. This function will return when all
405 * tasks have completed. When @ install_signals is GNUNET_YES, then
406 * this function behaves in the same was as GNUNET_SCHEDULER_run does.
407 * If @ install_signals is GNUNET_NO then no signal handlers are
408 * installed.
409 *
410 * @param install_signals whether to install signals (GNUNET_YES/NO)
411 * @param task task to run first (and immediately)
412 * @param task_cls closure of @a task
413 */
414void
415GNUNET_SCHEDULER_run_with_optional_signals (int install_signals,
416 GNUNET_SCHEDULER_TaskCallback task,
417 void *task_cls);
418
403 419
404/** 420/**
405 * Request the shutdown of a scheduler. Marks all tasks 421 * Request the shutdown of a scheduler. Marks all tasks
diff --git a/src/integration-tests/Makefile.am b/src/integration-tests/Makefile.am
index 6fff0b407..368980064 100644
--- a/src/integration-tests/Makefile.am
+++ b/src/integration-tests/Makefile.am
@@ -42,7 +42,8 @@ endif
42 42
43do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' 43do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g'
44 44
45%.py: %.py.in Makefile 45SUFFIXES = .py.in .py
46.py.in.py:
46 $(do_subst) < $(srcdir)/$< > $@ 47 $(do_subst) < $(srcdir)/$< > $@
47 chmod +x $@ 48 chmod +x $@
48 49
diff --git a/src/json/json_generator.c b/src/json/json_generator.c
index e660e10c5..98f7163bc 100644
--- a/src/json/json_generator.c
+++ b/src/json/json_generator.c
@@ -73,6 +73,19 @@ GNUNET_JSON_from_time_abs (struct GNUNET_TIME_Absolute stamp)
73 73
74 74
75/** 75/**
76 * Convert absolute timestamp to a json string.
77 *
78 * @param stamp the time stamp
79 * @return a json string with the timestamp in @a stamp
80 */
81json_t *
82GNUNET_JSON_from_time_abs_nbo (struct GNUNET_TIME_AbsoluteNBO stamp)
83{
84 return GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (stamp));
85}
86
87
88/**
76 * Convert relative timestamp to a json string. 89 * Convert relative timestamp to a json string.
77 * 90 *
78 * @param stamp the time stamp 91 * @param stamp the time stamp
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c
index 9d077f874..8281e9a16 100644
--- a/src/revocation/gnunet-service-revocation.c
+++ b/src/revocation/gnunet-service-revocation.c
@@ -509,6 +509,7 @@ transmit_task_cb (void *cls)
509 "Starting set exchange with peer `%s'\n", 509 "Starting set exchange with peer `%s'\n",
510 GNUNET_i2s (&peer_entry->id)); 510 GNUNET_i2s (&peer_entry->id));
511 peer_entry->transmit_task = NULL; 511 peer_entry->transmit_task = NULL;
512 GNUNET_assert (NULL == peer_entry->so);
512 peer_entry->so = GNUNET_SET_prepare (&peer_entry->id, 513 peer_entry->so = GNUNET_SET_prepare (&peer_entry->id,
513 &revocation_set_union_app_id, 514 &revocation_set_union_app_id,
514 NULL, 515 NULL,
@@ -758,6 +759,7 @@ handle_revocation_union_request (void *cls,
758 { 759 {
759 peer_entry = new_peer_entry (other_peer); 760 peer_entry = new_peer_entry (other_peer);
760 } 761 }
762 GNUNET_assert (NULL == peer_entry->so);
761 peer_entry->so = GNUNET_SET_accept (request, 763 peer_entry->so = GNUNET_SET_accept (request,
762 GNUNET_SET_RESULT_ADDED, 764 GNUNET_SET_RESULT_ADDED,
763 (struct GNUNET_SET_Option[]) {{ 0 }}, 765 (struct GNUNET_SET_Option[]) {{ 0 }},
diff --git a/src/secretsharing/Makefile.am b/src/secretsharing/Makefile.am
index 5ab8739af..c808e8200 100644
--- a/src/secretsharing/Makefile.am
+++ b/src/secretsharing/Makefile.am
@@ -47,7 +47,7 @@ libgnunetsecretsharing_la_SOURCES = \
47 secretsharing_api.c \ 47 secretsharing_api.c \
48 secretsharing_common.c \ 48 secretsharing_common.c \
49 secretsharing.h 49 secretsharing.h
50libgnunetsecretsharing_la_LIBADD = \ 50libgnunetsecretsharing_la_LIBADD = \
51 $(top_builddir)/src/util/libgnunetutil.la \ 51 $(top_builddir)/src/util/libgnunetutil.la \
52 $(LIBGCRYPT_LIBS) \ 52 $(LIBGCRYPT_LIBS) \
53 $(LTLIBINTL) 53 $(LTLIBINTL)
diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c
index 0e52dccfa..de680b11c 100644
--- a/src/social/gnunet-social.c
+++ b/src/social/gnunet-social.c
@@ -281,7 +281,7 @@ exit_fail ()
281 * This also indicates the end of the connection to the service. 281 * This also indicates the end of the connection to the service.
282 */ 282 */
283static void 283static void
284host_left () 284host_left (void *cls)
285{ 285{
286 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 286 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
287 "The host has left the place.\n"); 287 "The host has left the place.\n");
diff --git a/src/social/social_api.c b/src/social/social_api.c
index af1d6e57e..d57d16cfb 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -2693,6 +2693,8 @@ GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app,
2693 GNUNET_ContinuationCallback disconnect_cb, 2693 GNUNET_ContinuationCallback disconnect_cb,
2694 void *disconnect_cls) 2694 void *disconnect_cls)
2695{ 2695{
2696 if (NULL == app) return;
2697
2696 app->disconnect_cb = disconnect_cb; 2698 app->disconnect_cb = disconnect_cb;
2697 app->disconnect_cls = disconnect_cls; 2699 app->disconnect_cls = disconnect_cls;
2698 2700
diff --git a/src/sq/sq_result_helper.c b/src/sq/sq_result_helper.c
index 9579863b2..f2986a053 100644
--- a/src/sq/sq_result_helper.c
+++ b/src/sq/sq_result_helper.c
@@ -620,7 +620,7 @@ extract_uint16 (void *cls,
620 void *dst) 620 void *dst)
621{ 621{
622 uint64_t v; 622 uint64_t v;
623 uint32_t *u = dst; 623 uint16_t *u = dst;
624 624
625 GNUNET_assert (sizeof (uint16_t) == *dst_size); 625 GNUNET_assert (sizeof (uint16_t) == *dst_size);
626 if (SQLITE_INTEGER != 626 if (SQLITE_INTEGER !=
diff --git a/src/statistics/Makefile.am b/src/statistics/Makefile.am
index b2e256960..16a1ea2d0 100644
--- a/src/statistics/Makefile.am
+++ b/src/statistics/Makefile.am
@@ -90,7 +90,8 @@ endif
90 90
91do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' 91do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g'
92 92
93%.py: %.py.in Makefile 93SUFFIXES = .py.in .py
94.py.in.py:
94 $(do_subst) < $(srcdir)/$< > $@ 95 $(do_subst) < $(srcdir)/$< > $@
95 chmod +x $@ 96 chmod +x $@
96 97
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c
index 7bc36d1b4..7d0ccd269 100644
--- a/src/testbed/testbed_api_topology.c
+++ b/src/testbed/testbed_api_topology.c
@@ -1051,7 +1051,7 @@ gen_topo_from_file (struct TopologyContext *tc,
1051 state = PEER_INDEX; 1051 state = PEER_INDEX;
1052 while (offset < fs) 1052 while (offset < fs)
1053 { 1053 {
1054 if (0 != isspace (data[offset])) 1054 if (0 != isspace ((unsigned char) data[offset]))
1055 { 1055 {
1056 offset++; 1056 offset++;
1057 continue; 1057 continue;
diff --git a/src/topology/friends.c b/src/topology/friends.c
index a960fad17..65f2700bb 100644
--- a/src/topology/friends.c
+++ b/src/topology/friends.c
@@ -95,7 +95,7 @@ GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg,
95 pos = 0; 95 pos = 0;
96 while (pos < fsize) 96 while (pos < fsize)
97 { 97 {
98 while ((pos < fsize) && (! isspace ((int) data[pos]))) 98 while ((pos < fsize) && (! isspace ((unsigned char) data[pos])))
99 pos++; 99 pos++;
100 if (GNUNET_OK != 100 if (GNUNET_OK !=
101 GNUNET_CRYPTO_eddsa_public_key_from_string (&data[start], 101 GNUNET_CRYPTO_eddsa_public_key_from_string (&data[start],
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index ec4d82164..6b354df98 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -541,6 +541,13 @@ client_disconnect_cb (void *cls,
541 GNUNET_CONTAINER_multipeermap_iterate (active_stccs, 541 GNUNET_CONTAINER_multipeermap_iterate (active_stccs,
542 &mark_match_down, 542 &mark_match_down,
543 tc); 543 tc);
544 for (struct AddressToStringContext *cur = a2s_head;
545 NULL != cur;
546 cur = cur->next)
547 {
548 if (cur->tc == tc)
549 cur->tc = NULL;
550 }
544 GNUNET_CONTAINER_DLL_remove (clients_head, 551 GNUNET_CONTAINER_DLL_remove (clients_head,
545 clients_tail, 552 clients_tail,
546 tc); 553 tc);
@@ -864,6 +871,8 @@ transmit_address_to_client (void *cls,
864 871
865 GNUNET_assert ( (GNUNET_OK == res) || 872 GNUNET_assert ( (GNUNET_OK == res) ||
866 (GNUNET_SYSERR == res) ); 873 (GNUNET_SYSERR == res) );
874 if (NULL == actx->tc)
875 return;
867 if (NULL == buf) 876 if (NULL == buf)
868 { 877 {
869 env = GNUNET_MQ_msg (atsm, 878 env = GNUNET_MQ_msg (atsm,
@@ -878,6 +887,7 @@ transmit_address_to_client (void *cls,
878 GNUNET_CONTAINER_DLL_remove (a2s_head, 887 GNUNET_CONTAINER_DLL_remove (a2s_head,
879 a2s_tail, 888 a2s_tail,
880 actx); 889 actx);
890 GNUNET_free (actx);
881 return; 891 return;
882 } 892 }
883 if (GNUNET_SYSERR == res) 893 if (GNUNET_SYSERR == res)
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c
index a20c998b3..c780f9a78 100644
--- a/src/transport/gnunet-service-transport_ats.c
+++ b/src/transport/gnunet-service-transport_ats.c
@@ -344,8 +344,7 @@ GST_ats_block_address (const struct GNUNET_HELLO_Address *address,
344 } 344 }
345 if (NULL == ai->ar) 345 if (NULL == ai->ar)
346 { 346 {
347 /* already blocked, how did it get used!? */ 347 /* already blocked but this might be a blacklist check callback */
348 GNUNET_break (0);
349 return; 348 return;
350 } 349 }
351 ai->back_off = GNUNET_TIME_STD_BACKOFF (ai->back_off); 350 ai->back_off = GNUNET_TIME_STD_BACKOFF (ai->back_off);
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 4a6d427be..27c3c7041 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -784,15 +784,24 @@ revalidate_address (void *cls)
784 GNUNET_STATISTICS_update (GST_stats, 784 GNUNET_STATISTICS_update (GST_stats,
785 gettext_noop ("# address revalidations started"), 1, 785 gettext_noop ("# address revalidations started"), 1,
786 GNUNET_NO); 786 GNUNET_NO);
787 if (NULL != ve->bc)
788 {
789 GST_blacklist_test_cancel (ve->bc);
790 ve->bc = NULL;
791 }
787 bc = GST_blacklist_test_allowed (&ve->address->peer, 792 bc = GST_blacklist_test_allowed (&ve->address->peer,
788 ve->address->transport_name, 793 ve->address->transport_name,
789 &transmit_ping_if_allowed, 794 &transmit_ping_if_allowed,
790 ve, 795 ve,
791 NULL, 796 NULL,
792 NULL); 797 NULL);
793 if (NULL != bc) 798 if (NULL != bc)
794 ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already 799 {
795 * called... */ 800 /* If transmit_ping_if_allowed was already called it may have freed ve,
801 * so only set ve->bc if it has not been called.
802 */
803 ve->bc = bc;
804 }
796} 805}
797 806
798 807
diff --git a/src/transport/test_transport_testing_restart.c b/src/transport/test_transport_testing_restart.c
index 595177e03..06275055d 100644
--- a/src/transport/test_transport_testing_restart.c
+++ b/src/transport/test_transport_testing_restart.c
@@ -71,7 +71,8 @@ restart_cb (void *cls)
71 p->no, 71 p->no,
72 GNUNET_i2s (&p->id)); 72 GNUNET_i2s (&p->id));
73 ret = 0; 73 ret = 0;
74 end (); 74 GNUNET_SCHEDULER_add_now (&end,
75 NULL);
75} 76}
76 77
77 78
diff --git a/src/transport/test_transport_testing_startstop.c b/src/transport/test_transport_testing_startstop.c
index 6ac0250cc..931e922c4 100644
--- a/src/transport/test_transport_testing_startstop.c
+++ b/src/transport/test_transport_testing_startstop.c
@@ -71,7 +71,8 @@ start_cb (void *cls)
71 p->no, 71 p->no,
72 GNUNET_i2s (&p->id)); 72 GNUNET_i2s (&p->id));
73 ret = 0; 73 ret = 0;
74 end (); 74 GNUNET_SCHEDULER_add_now (&end,
75 NULL);
75} 76}
76 77
77 78
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 2aa6cdbb0..68cda3bd7 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -384,7 +384,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth
384{ 384{
385 char *emsg = NULL; 385 char *emsg = NULL;
386 struct GNUNET_TRANSPORT_TESTING_PeerContext *p; 386 struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
387 struct GNUNET_PeerIdentity *dummy; 387 struct GNUNET_PeerIdentity dummy;
388 unsigned int i; 388 unsigned int i;
389 389
390 if (GNUNET_NO == GNUNET_DISK_file_test (cfgname)) 390 if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
@@ -678,6 +678,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext
678 GNUNET_CONFIGURATION_destroy (p->cfg); 678 GNUNET_CONFIGURATION_destroy (p->cfg);
679 p->cfg = NULL; 679 p->cfg = NULL;
680 } 680 }
681 if (NULL != p->handlers)
682 {
683 GNUNET_free (p->handlers);
684 p->handlers = NULL;
685 }
681 GNUNET_CONTAINER_DLL_remove (tth->p_head, 686 GNUNET_CONTAINER_DLL_remove (tth->p_head,
682 tth->p_tail, 687 tth->p_tail,
683 p); 688 p);
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c
index eaa49a991..7845932ee 100644
--- a/src/util/crypto_ecc.c
+++ b/src/util/crypto_ecc.c
@@ -354,6 +354,37 @@ GNUNET_CRYPTO_eddsa_public_key_to_string (const struct GNUNET_CRYPTO_EddsaPublic
354 354
355 355
356/** 356/**
357 * Convert a private key to a string.
358 *
359 * @param priv key to convert
360 * @return string representing @a pub
361 */
362char *
363GNUNET_CRYPTO_eddsa_private_key_to_string (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
364{
365 char *privkeybuf;
366 size_t keylen = (sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)) * 8;
367 char *end;
368
369 if (keylen % 5 > 0)
370 keylen += 5 - keylen % 5;
371 keylen /= 5;
372 privkeybuf = GNUNET_malloc (keylen + 1);
373 end = GNUNET_STRINGS_data_to_string ((unsigned char *) priv,
374 sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey),
375 privkeybuf,
376 keylen);
377 if (NULL == end)
378 {
379 GNUNET_free (privkeybuf);
380 return NULL;
381 }
382 *end = '\0';
383 return privkeybuf;
384}
385
386
387/**
357 * Convert a string representing a public key to a public key. 388 * Convert a string representing a public key to a public key.
358 * 389 *
359 * @param enc encoded public key 390 * @param enc encoded public key
@@ -374,9 +405,10 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string (const char *enc,
374 if (enclen != keylen) 405 if (enclen != keylen)
375 return GNUNET_SYSERR; 406 return GNUNET_SYSERR;
376 407
377 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (enc, enclen, 408 if (GNUNET_OK !=
378 pub, 409 GNUNET_STRINGS_string_to_data (enc, enclen,
379 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) 410 pub,
411 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
380 return GNUNET_SYSERR; 412 return GNUNET_SYSERR;
381 return GNUNET_OK; 413 return GNUNET_OK;
382} 414}
@@ -403,9 +435,10 @@ GNUNET_CRYPTO_eddsa_public_key_from_string (const char *enc,
403 if (enclen != keylen) 435 if (enclen != keylen)
404 return GNUNET_SYSERR; 436 return GNUNET_SYSERR;
405 437
406 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (enc, enclen, 438 if (GNUNET_OK !=
407 pub, 439 GNUNET_STRINGS_string_to_data (enc, enclen,
408 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) 440 pub,
441 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
409 return GNUNET_SYSERR; 442 return GNUNET_SYSERR;
410 return GNUNET_OK; 443 return GNUNET_OK;
411} 444}
diff --git a/src/util/crypto_paillier.c b/src/util/crypto_paillier.c
index 3ed025a2a..530a2957f 100644
--- a/src/util/crypto_paillier.c
+++ b/src/util/crypto_paillier.c
@@ -370,9 +370,11 @@ GNUNET_CRYPTO_paillier_decrypt (const struct GNUNET_CRYPTO_PaillierPrivateKey *p
370 /* mod = cmum1 / n (mod n) */ 370 /* mod = cmum1 / n (mod n) */
371 GNUNET_assert (0 != (mod = gcry_mpi_new (0))); 371 GNUNET_assert (0 != (mod = gcry_mpi_new (0)));
372 gcry_mpi_div (mod, NULL, cmum1, n, 0); 372 gcry_mpi_div (mod, NULL, cmum1, n, 0);
373 gcry_mpi_release (cmum1);
373 374
374 /* m = mod * mu mod n */ 375 /* m = mod * mu mod n */
375 gcry_mpi_mulm (m, mod, mu, n); 376 gcry_mpi_mulm (m, mod, mu, n);
377 gcry_mpi_release (mod);
376 gcry_mpi_release (mu); 378 gcry_mpi_release (mu);
377 gcry_mpi_release (n); 379 gcry_mpi_release (n);
378} 380}
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index 7a108c21b..a985d8e59 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -1046,7 +1046,7 @@ GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key)
1046 * @return unblinded signature on success, NULL if RSA key is bad or malicious. 1046 * @return unblinded signature on success, NULL if RSA key is bad or malicious.
1047 */ 1047 */
1048struct GNUNET_CRYPTO_RsaSignature * 1048struct GNUNET_CRYPTO_RsaSignature *
1049GNUNET_CRYPTO_rsa_unblind (struct GNUNET_CRYPTO_RsaSignature *sig, 1049GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig,
1050 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, 1050 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
1051 struct GNUNET_CRYPTO_RsaPublicKey *pkey) 1051 struct GNUNET_CRYPTO_RsaPublicKey *pkey)
1052{ 1052{
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c
index 42ecc2101..66a4bd3e9 100644
--- a/src/util/gnunet-ecc.c
+++ b/src/util/gnunet-ecc.c
@@ -49,6 +49,11 @@ static unsigned int list_keys_count;
49static int print_public_key; 49static int print_public_key;
50 50
51/** 51/**
52 * Flag for printing private key.
53 */
54static int print_private_key;
55
56/**
52 * Flag for printing public key in hex. 57 * Flag for printing public key in hex.
53 */ 58 */
54static int print_public_key_hex; 59static int print_public_key_hex;
@@ -377,7 +382,7 @@ run (void *cls, char *const *args, const char *cfgfile,
377 create_keys (args[0], args[1]); 382 create_keys (args[0], args[1]);
378 return; 383 return;
379 } 384 }
380 if (print_public_key || print_public_key_hex) 385 if (print_public_key || print_public_key_hex || print_private_key)
381 { 386 {
382 char *str; 387 char *str;
383 struct GNUNET_DISK_FileHandle *keyfile; 388 struct GNUNET_DISK_FileHandle *keyfile;
@@ -388,19 +393,26 @@ run (void *cls, char *const *args, const char *cfgfile,
388 GNUNET_DISK_PERM_NONE); 393 GNUNET_DISK_PERM_NONE);
389 if (NULL == keyfile) 394 if (NULL == keyfile)
390 return; 395 return;
391 while (sizeof (pk) == GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk))) 396 while (sizeof (pk) ==
397 GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk)))
392 { 398 {
393 GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub); 399 GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub);
394 if (print_public_key_hex) 400 if (print_public_key_hex)
395 { 401 {
396 print_hex ("HEX:", &pub, sizeof (pub)); 402 print_hex ("HEX:", &pub, sizeof (pub));
397 } 403 }
398 else 404 else if (print_public_key)
399 { 405 {
400 str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); 406 str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub);
401 FPRINTF (stdout, "%s\n", str); 407 FPRINTF (stdout, "%s\n", str);
402 GNUNET_free (str); 408 GNUNET_free (str);
403 } 409 }
410 else if (print_private_key)
411 {
412 str = GNUNET_CRYPTO_eddsa_private_key_to_string (&pk);
413 FPRINTF (stdout, "%s\n", str);
414 GNUNET_free (str);
415 }
404 } 416 }
405 GNUNET_DISK_file_close (keyfile); 417 GNUNET_DISK_file_close (keyfile);
406 } 418 }
@@ -438,6 +450,10 @@ main (int argc,
438 "print-public-key", 450 "print-public-key",
439 gettext_noop ("print the public key in ASCII format"), 451 gettext_noop ("print the public key in ASCII format"),
440 &print_public_key), 452 &print_public_key),
453 GNUNET_GETOPT_option_flag ('P',
454 "print-private-key",
455 gettext_noop ("print the private key in ASCII format"),
456 &print_private_key),
441 GNUNET_GETOPT_option_flag ('x', 457 GNUNET_GETOPT_option_flag ('x',
442 "print-hex", 458 "print-hex",
443 gettext_noop ("print the public key in HEX format"), 459 gettext_noop ("print the public key in HEX format"),
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 33a340729..11b8134d6 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -469,6 +469,7 @@ handle_response (void *cls,
469 uint16_t size; 469 uint16_t size;
470 char *nret; 470 char *nret;
471 471
472 GNUNET_assert (NULL != rh);
472 size = ntohs (msg->size); 473 size = ntohs (msg->size);
473 if (size == sizeof (struct GNUNET_MessageHeader)) 474 if (size == sizeof (struct GNUNET_MessageHeader))
474 { 475 {
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index e9c25d68a..540a60557 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -787,6 +787,14 @@ void
787GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, 787GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task,
788 void *task_cls) 788 void *task_cls)
789{ 789{
790 GNUNET_SCHEDULER_run_with_optional_signals(GNUNET_YES, task, task_cls);
791}
792
793void
794GNUNET_SCHEDULER_run_with_optional_signals (int install_signals,
795 GNUNET_SCHEDULER_TaskCallback task,
796 void *task_cls)
797{
790 struct GNUNET_NETWORK_FDSet *rs; 798 struct GNUNET_NETWORK_FDSet *rs;
791 struct GNUNET_NETWORK_FDSet *ws; 799 struct GNUNET_NETWORK_FDSet *ws;
792 struct GNUNET_TIME_Relative timeout; 800 struct GNUNET_TIME_Relative timeout;
@@ -820,24 +828,29 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task,
820 GNUNET_DISK_PIPE_END_READ); 828 GNUNET_DISK_PIPE_END_READ);
821 GNUNET_assert (NULL != pr); 829 GNUNET_assert (NULL != pr);
822 my_pid = getpid (); 830 my_pid = getpid ();
823 LOG (GNUNET_ERROR_TYPE_DEBUG, 831
824 "Registering signal handlers\n"); 832 if (GNUNET_YES == install_signals)
825 shc_int = GNUNET_SIGNAL_handler_install (SIGINT, 833 {
834 LOG (GNUNET_ERROR_TYPE_DEBUG,
835 "Registering signal handlers\n");
836 shc_int = GNUNET_SIGNAL_handler_install (SIGINT,
837 &sighandler_shutdown);
838 shc_term = GNUNET_SIGNAL_handler_install (SIGTERM,
826 &sighandler_shutdown); 839 &sighandler_shutdown);
827 shc_term = GNUNET_SIGNAL_handler_install (SIGTERM,
828 &sighandler_shutdown);
829#if (SIGTERM != GNUNET_TERM_SIG) 840#if (SIGTERM != GNUNET_TERM_SIG)
830 shc_gterm = GNUNET_SIGNAL_handler_install (GNUNET_TERM_SIG, 841 shc_gterm = GNUNET_SIGNAL_handler_install (GNUNET_TERM_SIG,
831 &sighandler_shutdown); 842 &sighandler_shutdown);
832#endif 843#endif
833#ifndef MINGW 844#ifndef MINGW
834 shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE, 845 shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE,
835 &sighandler_pipe); 846 &sighandler_pipe);
836 shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, 847 shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT,
837 &sighandler_shutdown); 848 &sighandler_shutdown);
838 shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, 849 shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP,
839 &sighandler_shutdown); 850 &sighandler_shutdown);
840#endif 851#endif
852 }
853
841 current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; 854 current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT;
842 current_lifeness = GNUNET_YES; 855 current_lifeness = GNUNET_YES;
843 GNUNET_SCHEDULER_add_with_reason_and_priority (task, 856 GNUNET_SCHEDULER_add_with_reason_and_priority (task,
@@ -953,16 +966,21 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task,
953 busy_wait_warning = 0; 966 busy_wait_warning = 0;
954 } 967 }
955 } 968 }
956 GNUNET_SIGNAL_handler_uninstall (shc_int); 969
957 GNUNET_SIGNAL_handler_uninstall (shc_term); 970 if (GNUNET_YES == install_signals)
971 {
972 GNUNET_SIGNAL_handler_uninstall (shc_int);
973 GNUNET_SIGNAL_handler_uninstall (shc_term);
958#if (SIGTERM != GNUNET_TERM_SIG) 974#if (SIGTERM != GNUNET_TERM_SIG)
959 GNUNET_SIGNAL_handler_uninstall (shc_gterm); 975 GNUNET_SIGNAL_handler_uninstall (shc_gterm);
960#endif 976#endif
961#ifndef MINGW 977#ifndef MINGW
962 GNUNET_SIGNAL_handler_uninstall (shc_pipe); 978 GNUNET_SIGNAL_handler_uninstall (shc_pipe);
963 GNUNET_SIGNAL_handler_uninstall (shc_quit); 979 GNUNET_SIGNAL_handler_uninstall (shc_quit);
964 GNUNET_SIGNAL_handler_uninstall (shc_hup); 980 GNUNET_SIGNAL_handler_uninstall (shc_hup);
965#endif 981#endif
982 }
983
966 GNUNET_DISK_pipe_close (shutdown_pipe_handle); 984 GNUNET_DISK_pipe_close (shutdown_pipe_handle);
967 shutdown_pipe_handle = NULL; 985 shutdown_pipe_handle = NULL;
968 GNUNET_NETWORK_fdset_destroy (rs); 986 GNUNET_NETWORK_fdset_destroy (rs);
diff --git a/src/util/test_crypto_paillier.c b/src/util/test_crypto_paillier.c
index 9950978c1..1e7e0b301 100644
--- a/src/util/test_crypto_paillier.c
+++ b/src/util/test_crypto_paillier.c
@@ -37,6 +37,7 @@ test_crypto ()
37 struct GNUNET_CRYPTO_PaillierCiphertext ciphertext; 37 struct GNUNET_CRYPTO_PaillierCiphertext ciphertext;
38 struct GNUNET_CRYPTO_PaillierPublicKey public_key; 38 struct GNUNET_CRYPTO_PaillierPublicKey public_key;
39 struct GNUNET_CRYPTO_PaillierPrivateKey private_key; 39 struct GNUNET_CRYPTO_PaillierPrivateKey private_key;
40 int ret = 0;
40 41
41 GNUNET_CRYPTO_paillier_create (&public_key, 42 GNUNET_CRYPTO_paillier_create (&public_key,
42 &private_key); 43 &private_key);
@@ -54,7 +55,6 @@ test_crypto ()
54 &public_key, 55 &public_key,
55 &ciphertext, 56 &ciphertext,
56 plaintext_result); 57 plaintext_result);
57
58 if (0 != gcry_mpi_cmp (plaintext, 58 if (0 != gcry_mpi_cmp (plaintext,
59 plaintext_result)) 59 plaintext_result))
60 { 60 {
@@ -65,9 +65,11 @@ test_crypto ()
65 plaintext); 65 plaintext);
66 gcry_log_debugmpi ("\n", 66 gcry_log_debugmpi ("\n",
67 plaintext_result); 67 plaintext_result);
68 return 1; 68 ret = 1;
69 } 69 }
70 return 0; 70 gcry_mpi_release (plaintext);
71 gcry_mpi_release (plaintext_result);
72 return ret;
71} 73}
72 74
73 75
@@ -84,6 +86,7 @@ test_hom_simple (unsigned int a,
84 struct GNUNET_CRYPTO_PaillierCiphertext c_result; 86 struct GNUNET_CRYPTO_PaillierCiphertext c_result;
85 struct GNUNET_CRYPTO_PaillierPublicKey public_key; 87 struct GNUNET_CRYPTO_PaillierPublicKey public_key;
86 struct GNUNET_CRYPTO_PaillierPrivateKey private_key; 88 struct GNUNET_CRYPTO_PaillierPrivateKey private_key;
89 int ret = 0;
87 90
88 GNUNET_CRYPTO_paillier_create (&public_key, 91 GNUNET_CRYPTO_paillier_create (&public_key,
89 &private_key); 92 &private_key);
@@ -119,9 +122,13 @@ test_hom_simple (unsigned int a,
119 "GNUNET_CRYPTO_paillier failed simple math!\n"); 122 "GNUNET_CRYPTO_paillier failed simple math!\n");
120 gcry_log_debugmpi ("got ", hom_result); 123 gcry_log_debugmpi ("got ", hom_result);
121 gcry_log_debugmpi ("wanted ", result); 124 gcry_log_debugmpi ("wanted ", result);
122 return 1; 125 ret = 1;
123 } 126 }
124 return 0; 127 gcry_mpi_release (m1);
128 gcry_mpi_release (m2);
129 gcry_mpi_release (result);
130 gcry_mpi_release (hom_result);
131 return ret;
125} 132}
126 133
127 134
@@ -168,7 +175,8 @@ test_hom ()
168 fprintf (stderr, 175 fprintf (stderr,
169 "GNUNET_CRYPTO_paillier_encrypt 1 failed, should return 1 allowed operation, got %d!\n", 176 "GNUNET_CRYPTO_paillier_encrypt 1 failed, should return 1 allowed operation, got %d!\n",
170 ret); 177 ret);
171 return 1; 178 ret = 1;
179 goto out;
172 } 180 }
173 if (2 != (ret = GNUNET_CRYPTO_paillier_encrypt (&public_key, 181 if (2 != (ret = GNUNET_CRYPTO_paillier_encrypt (&public_key,
174 m2, 182 m2,
@@ -178,7 +186,8 @@ test_hom ()
178 fprintf (stderr, 186 fprintf (stderr,
179 "GNUNET_CRYPTO_paillier_encrypt 2 failed, should return 2 allowed operation, got %d!\n", 187 "GNUNET_CRYPTO_paillier_encrypt 2 failed, should return 2 allowed operation, got %d!\n",
180 ret); 188 ret);
181 return 1; 189 ret = 1;
190 goto out;
182 } 191 }
183 192
184 if (0 != (ret = GNUNET_CRYPTO_paillier_hom_add (&public_key, 193 if (0 != (ret = GNUNET_CRYPTO_paillier_hom_add (&public_key,
@@ -189,7 +198,8 @@ test_hom ()
189 fprintf (stderr, 198 fprintf (stderr,
190 "GNUNET_CRYPTO_paillier_hom_add failed, expected 0 remaining operations, got %d!\n", 199 "GNUNET_CRYPTO_paillier_hom_add failed, expected 0 remaining operations, got %d!\n",
191 ret); 200 ret);
192 return 1; 201 ret = 1;
202 goto out;
193 } 203 }
194 204
195 GNUNET_CRYPTO_paillier_decrypt (&private_key, 205 GNUNET_CRYPTO_paillier_decrypt (&private_key,
@@ -203,9 +213,14 @@ test_hom ()
203 "GNUNET_CRYPTO_paillier miscalculated with large numbers!\n"); 213 "GNUNET_CRYPTO_paillier miscalculated with large numbers!\n");
204 gcry_log_debugmpi ("got", hom_result); 214 gcry_log_debugmpi ("got", hom_result);
205 gcry_log_debugmpi ("wanted", result); 215 gcry_log_debugmpi ("wanted", result);
206 return 1; 216 ret = 1;
207 } 217 }
208 return 0; 218out:
219 gcry_mpi_release (m1);
220 gcry_mpi_release (m2);
221 gcry_mpi_release (result);
222 gcry_mpi_release (hom_result);
223 return ret;
209} 224}
210 225
211 226
diff --git a/src/util/test_mq.c b/src/util/test_mq.c
index 442c110db..9e8fc844e 100644
--- a/src/util/test_mq.c
+++ b/src/util/test_mq.c
@@ -51,6 +51,7 @@ test1 ()
51 GNUNET_assert (NULL != mm); 51 GNUNET_assert (NULL != mm);
52 GNUNET_assert (42 == ntohs (mm->header.type)); 52 GNUNET_assert (42 == ntohs (mm->header.type));
53 GNUNET_assert (sizeof (struct MyMessage) == ntohs (mm->header.size)); 53 GNUNET_assert (sizeof (struct MyMessage) == ntohs (mm->header.size));
54 GNUNET_MQ_discard (mqm);
54} 55}
55 56
56 57