diff options
author | t3sserakt <t3ss@posteo.de> | 2021-11-09 17:54:23 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-11-09 19:43:13 +0100 |
commit | 7b575e69c8843fd779f72ad8fed7a8360a3ba513 (patch) | |
tree | f88ae0dd8ce1528751da708ee824b13d2f898f21 /src | |
parent | 8cd4dadfb9ebd4db232fda79d5c4353eacb15690 (diff) | |
parent | fab39a6089cb6f48af6bdcfa0a4df3559348259e (diff) | |
download | gnunet-7b575e69c8843fd779f72ad8fed7a8360a3ba513.tar.gz gnunet-7b575e69c8843fd779f72ad8fed7a8360a3ba513.zip |
Merge branch 'master' into dev/t3ss/tng
Diffstat (limited to 'src')
-rw-r--r-- | src/dhtu/Makefile.am | 2 | ||||
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 17 | ||||
-rw-r--r-- | src/include/gnunet_json_lib.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_os_lib.h | 4 | ||||
-rw-r--r-- | src/json/json.c | 2 | ||||
-rw-r--r-- | src/json/json_helper.c | 5 | ||||
-rw-r--r-- | src/pq/pq.c | 8 | ||||
-rw-r--r-- | src/pq/pq_exec.c | 5 | ||||
-rw-r--r-- | src/pq/pq_result_helper.c | 43 | ||||
-rw-r--r-- | src/util/configuration.c | 15 | ||||
-rw-r--r-- | src/util/crypto_hkdf.c | 23 | ||||
-rw-r--r-- | src/util/crypto_rsa.c | 23 | ||||
-rw-r--r-- | src/util/os_installation.c | 20 |
13 files changed, 106 insertions, 65 deletions
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am index 772bee60a..0e10721cd 100644 --- a/src/dhtu/Makefile.am +++ b/src/dhtu/Makefile.am | |||
@@ -48,6 +48,7 @@ libgnunettestingdhtu_la_SOURCES = \ | |||
48 | testing_dhtu_cmd_send.c | 48 | testing_dhtu_cmd_send.c |
49 | libgnunettestingdhtu_la_LIBADD = \ | 49 | libgnunettestingdhtu_la_LIBADD = \ |
50 | $(top_builddir)/src/testing/libgnunettesting.la \ | 50 | $(top_builddir)/src/testing/libgnunettesting.la \ |
51 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
51 | $(top_builddir)/src/util/libgnunetutil.la \ | 52 | $(top_builddir)/src/util/libgnunetutil.la \ |
52 | $(LTLIBINTL) | 53 | $(LTLIBINTL) |
53 | libgnunettestingdhtu_la_LDFLAGS = \ | 54 | libgnunettestingdhtu_la_LDFLAGS = \ |
@@ -60,6 +61,7 @@ test_dhtu_ip_SOURCES = \ | |||
60 | test_dhtu_ip.c | 61 | test_dhtu_ip.c |
61 | test_dhtu_ip_LDADD = \ | 62 | test_dhtu_ip_LDADD = \ |
62 | $(top_builddir)/src/testing/libgnunettesting.la \ | 63 | $(top_builddir)/src/testing/libgnunettesting.la \ |
64 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
63 | $(top_builddir)/src/util/libgnunetutil.la | 65 | $(top_builddir)/src/util/libgnunetutil.la |
64 | 66 | ||
65 | check_PROGRAMS = \ | 67 | check_PROGRAMS = \ |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index e754756e5..0eb2ea8cd 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -1260,7 +1260,7 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string ( | |||
1260 | * @param priv where to store the private key | 1260 | * @param priv where to store the private key |
1261 | * @return #GNUNET_OK on success | 1261 | * @return #GNUNET_OK on success |
1262 | */ | 1262 | */ |
1263 | int | 1263 | enum GNUNET_GenericReturnValue |
1264 | GNUNET_CRYPTO_eddsa_private_key_from_string ( | 1264 | GNUNET_CRYPTO_eddsa_private_key_from_string ( |
1265 | const char *enc, | 1265 | const char *enc, |
1266 | size_t enclen, | 1266 | size_t enclen, |
@@ -1318,7 +1318,7 @@ GNUNET_CRYPTO_ecdsa_key_from_file (const char *filename, | |||
1318 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but | 1318 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but |
1319 | * we found an existing file, #GNUNET_SYSERR on failure | 1319 | * we found an existing file, #GNUNET_SYSERR on failure |
1320 | */ | 1320 | */ |
1321 | int | 1321 | enum GNUNET_GenericReturnValue |
1322 | GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, | 1322 | GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, |
1323 | int do_create, | 1323 | int do_create, |
1324 | struct GNUNET_CRYPTO_EddsaPrivateKey *pkey); | 1324 | struct GNUNET_CRYPTO_EddsaPrivateKey *pkey); |
@@ -1794,7 +1794,7 @@ GNUNET_CRYPTO_ecdsa_sign_ ( | |||
1794 | * @param pub public key of the signer | 1794 | * @param pub public key of the signer |
1795 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 1795 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
1796 | */ | 1796 | */ |
1797 | int | 1797 | enum GNUNET_GenericReturnValue |
1798 | GNUNET_CRYPTO_eddsa_verify_ ( | 1798 | GNUNET_CRYPTO_eddsa_verify_ ( |
1799 | uint32_t purpose, | 1799 | uint32_t purpose, |
1800 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 1800 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
@@ -1847,7 +1847,7 @@ GNUNET_CRYPTO_eddsa_verify_ ( | |||
1847 | * @param pub public key of the signer | 1847 | * @param pub public key of the signer |
1848 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 1848 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
1849 | */ | 1849 | */ |
1850 | int | 1850 | enum GNUNET_GenericReturnValue |
1851 | GNUNET_CRYPTO_ecdsa_verify_ ( | 1851 | GNUNET_CRYPTO_ecdsa_verify_ ( |
1852 | uint32_t purpose, | 1852 | uint32_t purpose, |
1853 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 1853 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
@@ -2257,7 +2257,8 @@ GNUNET_CRYPTO_rsa_public_key_encode ( | |||
2257 | * @return NULL on error | 2257 | * @return NULL on error |
2258 | */ | 2258 | */ |
2259 | struct GNUNET_CRYPTO_RsaPublicKey * | 2259 | struct GNUNET_CRYPTO_RsaPublicKey * |
2260 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len); | 2260 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, |
2261 | size_t len); | ||
2261 | 2262 | ||
2262 | 2263 | ||
2263 | /** | 2264 | /** |
@@ -2289,9 +2290,9 @@ GNUNET_CRYPTO_rsa_signature_cmp (const struct GNUNET_CRYPTO_RsaSignature *s1, | |||
2289 | * @return 0 if the two are equal | 2290 | * @return 0 if the two are equal |
2290 | */ | 2291 | */ |
2291 | int | 2292 | int |
2292 | GNUNET_CRYPTO_rsa_private_key_cmp (const struct GNUNET_CRYPTO_RsaPrivateKey *p1, | 2293 | GNUNET_CRYPTO_rsa_private_key_cmp ( |
2293 | const struct | 2294 | const struct GNUNET_CRYPTO_RsaPrivateKey *p1, |
2294 | GNUNET_CRYPTO_RsaPrivateKey *p2); | 2295 | const struct GNUNET_CRYPTO_RsaPrivateKey *p2); |
2295 | 2296 | ||
2296 | 2297 | ||
2297 | /** | 2298 | /** |
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h index 92f696e08..5ef4592e5 100644 --- a/src/include/gnunet_json_lib.h +++ b/src/include/gnunet_json_lib.h | |||
@@ -107,9 +107,9 @@ struct GNUNET_JSON_Specification | |||
107 | size_t *size_ptr; | 107 | size_t *size_ptr; |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * Set to #GNUNET_YES if this component is optional. | 110 | * Set to true if this component is optional. |
111 | */ | 111 | */ |
112 | int is_optional; | 112 | bool is_optional; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | 115 | ||
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index 749f766d2..eddf97dab 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h | |||
@@ -672,9 +672,9 @@ GNUNET_OS_install_parent_control_handler (void *cls); | |||
672 | * #GNUNET_NO if not SUID (but binary exists), | 672 | * #GNUNET_NO if not SUID (but binary exists), |
673 | * #GNUNET_SYSERR on error (no such binary or not executable) | 673 | * #GNUNET_SYSERR on error (no such binary or not executable) |
674 | */ | 674 | */ |
675 | int | 675 | enum GNUNET_GenericReturnValue |
676 | GNUNET_OS_check_helper_binary (const char *binary, | 676 | GNUNET_OS_check_helper_binary (const char *binary, |
677 | int check_suid, | 677 | bool check_suid, |
678 | const char *params); | 678 | const char *params); |
679 | 679 | ||
680 | 680 | ||
diff --git a/src/json/json.c b/src/json/json.c index 51d5c0c72..6d11b4fdd 100644 --- a/src/json/json.c +++ b/src/json/json.c | |||
@@ -77,7 +77,7 @@ GNUNET_JSON_spec_mark_optional (struct GNUNET_JSON_Specification spec) | |||
77 | { | 77 | { |
78 | struct GNUNET_JSON_Specification ret = spec; | 78 | struct GNUNET_JSON_Specification ret = spec; |
79 | 79 | ||
80 | ret.is_optional = GNUNET_YES; | 80 | ret.is_optional = true; |
81 | return ret; | 81 | return ret; |
82 | } | 82 | } |
83 | 83 | ||
diff --git a/src/json/json_helper.c b/src/json/json_helper.c index 55435ea19..3a11f205c 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c | |||
@@ -847,11 +847,8 @@ GNUNET_JSON_spec_rsa_public_key (const char *name, | |||
847 | struct GNUNET_JSON_Specification ret = { | 847 | struct GNUNET_JSON_Specification ret = { |
848 | .parser = &parse_rsa_public_key, | 848 | .parser = &parse_rsa_public_key, |
849 | .cleaner = &clean_rsa_public_key, | 849 | .cleaner = &clean_rsa_public_key, |
850 | .cls = NULL, | ||
851 | .field = name, | 850 | .field = name, |
852 | .ptr = pk, | 851 | .ptr = pk |
853 | .ptr_size = 0, | ||
854 | .size_ptr = NULL | ||
855 | }; | 852 | }; |
856 | 853 | ||
857 | *pk = NULL; | 854 | *pk = NULL; |
diff --git a/src/pq/pq.c b/src/pq/pq.c index b260aa1db..130ff355f 100644 --- a/src/pq/pq.c +++ b/src/pq/pq.c | |||
@@ -95,6 +95,11 @@ GNUNET_PQ_exec_prepared (struct GNUNET_PQ_Context *db, | |||
95 | param_lengths, | 95 | param_lengths, |
96 | param_formats, | 96 | param_formats, |
97 | 1); | 97 | 1); |
98 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | ||
99 | "pq", | ||
100 | "Execution of prepared SQL statement `%s' finished (%d)\n", | ||
101 | name, | ||
102 | PGRES_COMMAND_OK == PQresultStatus (res)); | ||
98 | if ( (PGRES_COMMAND_OK != PQresultStatus (res)) && | 103 | if ( (PGRES_COMMAND_OK != PQresultStatus (res)) && |
99 | (CONNECTION_OK != (status = PQstatus (db->conn))) ) | 104 | (CONNECTION_OK != (status = PQstatus (db->conn))) ) |
100 | { | 105 | { |
@@ -163,6 +168,9 @@ GNUNET_PQ_extract_result (PGresult *result, | |||
163 | spec->fname); | 168 | spec->fname); |
164 | goto cleanup; | 169 | goto cleanup; |
165 | case GNUNET_SYSERR: | 170 | case GNUNET_SYSERR: |
171 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
172 | "Failed to extract field `%s'\n", | ||
173 | spec->fname); | ||
166 | GNUNET_break (0); | 174 | GNUNET_break (0); |
167 | goto cleanup; | 175 | goto cleanup; |
168 | } | 176 | } |
diff --git a/src/pq/pq_exec.c b/src/pq/pq_exec.c index 464fff4b4..dcde331b6 100644 --- a/src/pq/pq_exec.c +++ b/src/pq/pq_exec.c | |||
@@ -86,6 +86,11 @@ GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db, | |||
86 | db); | 86 | db); |
87 | result = PQexec (db->conn, | 87 | result = PQexec (db->conn, |
88 | es[i].sql); | 88 | es[i].sql); |
89 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
90 | "Running statement `%s' on %p finished (%d)\n", | ||
91 | es[i].sql, | ||
92 | db, | ||
93 | PGRES_COMMAND_OK == PQresultStatus (result)); | ||
89 | if ((GNUNET_NO == es[i].ignore_errors) && | 94 | if ((GNUNET_NO == es[i].ignore_errors) && |
90 | (PGRES_COMMAND_OK != PQresultStatus (result))) | 95 | (PGRES_COMMAND_OK != PQresultStatus (result))) |
91 | { | 96 | { |
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 23fb4f96e..f264603f4 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -127,10 +127,13 @@ GNUNET_PQ_result_spec_variable_size (const char *name, | |||
127 | void **dst, | 127 | void **dst, |
128 | size_t *sptr) | 128 | size_t *sptr) |
129 | { | 129 | { |
130 | struct GNUNET_PQ_ResultSpec res = | 130 | struct GNUNET_PQ_ResultSpec res = { |
131 | { &extract_varsize_blob, | 131 | .conv = &extract_varsize_blob, |
132 | &clean_varsize_blob, NULL, | 132 | .cleaner = &clean_varsize_blob, |
133 | (void *) (dst), 0, name, sptr }; | 133 | .dst = (void *) (dst), |
134 | .fname = name, | ||
135 | .result_size = sptr | ||
136 | }; | ||
134 | 137 | ||
135 | return res; | 138 | return res; |
136 | } | 139 | } |
@@ -207,10 +210,12 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, | |||
207 | void *dst, | 210 | void *dst, |
208 | size_t dst_size) | 211 | size_t dst_size) |
209 | { | 212 | { |
210 | struct GNUNET_PQ_ResultSpec res = | 213 | struct GNUNET_PQ_ResultSpec res = { |
211 | { &extract_fixed_blob, | 214 | .conv = &extract_fixed_blob, |
212 | NULL, NULL, | 215 | .dst = (dst), |
213 | (dst), dst_size, name, NULL }; | 216 | .dst_size = dst_size, |
217 | .fname = name | ||
218 | }; | ||
214 | 219 | ||
215 | return res; | 220 | return res; |
216 | } | 221 | } |
@@ -301,11 +306,12 @@ struct GNUNET_PQ_ResultSpec | |||
301 | GNUNET_PQ_result_spec_rsa_public_key (const char *name, | 306 | GNUNET_PQ_result_spec_rsa_public_key (const char *name, |
302 | struct GNUNET_CRYPTO_RsaPublicKey **rsa) | 307 | struct GNUNET_CRYPTO_RsaPublicKey **rsa) |
303 | { | 308 | { |
304 | struct GNUNET_PQ_ResultSpec res = | 309 | struct GNUNET_PQ_ResultSpec res = { |
305 | { &extract_rsa_public_key, | 310 | .conv = &extract_rsa_public_key, |
306 | &clean_rsa_public_key, | 311 | .cleaner = &clean_rsa_public_key, |
307 | NULL, | 312 | .dst = (void *) rsa, |
308 | (void *) rsa, 0, name, NULL }; | 313 | .fname = name |
314 | }; | ||
309 | 315 | ||
310 | return res; | 316 | return res; |
311 | } | 317 | } |
@@ -395,11 +401,12 @@ struct GNUNET_PQ_ResultSpec | |||
395 | GNUNET_PQ_result_spec_rsa_signature (const char *name, | 401 | GNUNET_PQ_result_spec_rsa_signature (const char *name, |
396 | struct GNUNET_CRYPTO_RsaSignature **sig) | 402 | struct GNUNET_CRYPTO_RsaSignature **sig) |
397 | { | 403 | { |
398 | struct GNUNET_PQ_ResultSpec res = | 404 | struct GNUNET_PQ_ResultSpec res = { |
399 | { &extract_rsa_signature, | 405 | .conv = &extract_rsa_signature, |
400 | &clean_rsa_signature, | 406 | .cleaner = &clean_rsa_signature, |
401 | NULL, | 407 | .dst = (void *) sig, |
402 | (void *) sig, 0, (name), NULL }; | 408 | .fname = name |
409 | }; | ||
403 | 410 | ||
404 | return res; | 411 | return res; |
405 | } | 412 | } |
diff --git a/src/util/configuration.c b/src/util/configuration.c index 09a3a7d93..d9d6721cc 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -2383,31 +2383,34 @@ GNUNET_CONFIGURATION_default (void) | |||
2383 | char *cfgname = NULL; | 2383 | char *cfgname = NULL; |
2384 | struct GNUNET_CONFIGURATION_Handle *cfg; | 2384 | struct GNUNET_CONFIGURATION_Handle *cfg; |
2385 | 2385 | ||
2386 | /* FIXME: Why are we doing this? Needs some commentary! */ | 2386 | /* Makes sure function implicitly looking at the installation directory (for |
2387 | example GNUNET_CONFIGURATION_load further down) use GNUnet's environment | ||
2388 | instead of the caller's. It's done at the start to make sure as many | ||
2389 | functions as possible are directed to the proper paths. */ | ||
2387 | GNUNET_OS_init (dpd); | 2390 | GNUNET_OS_init (dpd); |
2388 | 2391 | ||
2389 | cfg = GNUNET_CONFIGURATION_create (); | 2392 | cfg = GNUNET_CONFIGURATION_create (); |
2390 | 2393 | ||
2391 | /* First, try user configuration. */ | 2394 | /* First, try user configuration. */ |
2392 | if (NULL != xdg) | 2395 | if (NULL != xdg) |
2393 | GNUNET_asprintf (&cfgname, "%s/%s", xdg, pd->config_file); | 2396 | GNUNET_asprintf (&cfgname, "%s/%s", xdg, dpd->config_file); |
2394 | else | 2397 | else |
2395 | cfgname = GNUNET_strdup (pd->user_config_file); | 2398 | cfgname = GNUNET_strdup (dpd->user_config_file); |
2396 | 2399 | ||
2397 | /* If user config doesn't exist, try in | 2400 | /* If user config doesn't exist, try in |
2398 | /etc/<projdir>/<cfgfile> and /etc/<cfgfile> */ | 2401 | /etc/<projdir>/<cfgfile> and /etc/<cfgfile> */ |
2399 | if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) | 2402 | if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) |
2400 | { | 2403 | { |
2401 | GNUNET_free (cfgname); | 2404 | GNUNET_free (cfgname); |
2402 | GNUNET_asprintf (&cfgname, "/etc/%s", pd->config_file); | 2405 | GNUNET_asprintf (&cfgname, "/etc/%s", dpd->config_file); |
2403 | } | 2406 | } |
2404 | if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) | 2407 | if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) |
2405 | { | 2408 | { |
2406 | GNUNET_free (cfgname); | 2409 | GNUNET_free (cfgname); |
2407 | GNUNET_asprintf (&cfgname, | 2410 | GNUNET_asprintf (&cfgname, |
2408 | "/etc/%s/%s", | 2411 | "/etc/%s/%s", |
2409 | pd->project_dirname, | 2412 | dpd->project_dirname, |
2410 | pd->config_file); | 2413 | dpd->config_file); |
2411 | } | 2414 | } |
2412 | if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) | 2415 | if (GNUNET_OK != GNUNET_DISK_file_test (cfgname)) |
2413 | { | 2416 | { |
diff --git a/src/util/crypto_hkdf.c b/src/util/crypto_hkdf.c index 7270b87b6..4e4496819 100644 --- a/src/util/crypto_hkdf.c +++ b/src/util/crypto_hkdf.c | |||
@@ -103,11 +103,30 @@ getPRK (gcry_md_hd_t mac, const void *xts, size_t xts_len, const void *skm, | |||
103 | size_t skm_len, void *prk) | 103 | size_t skm_len, void *prk) |
104 | { | 104 | { |
105 | const void *ret; | 105 | const void *ret; |
106 | size_t dlen; | ||
106 | 107 | ||
107 | ret = doHMAC (mac, xts, xts_len, skm, skm_len); | 108 | dlen = gcry_md_get_algo_dlen (gcry_md_get_algo (mac)); |
109 | |||
110 | /* sanity check to bound stack allocation */ | ||
111 | GNUNET_assert (dlen <= 512); | ||
112 | |||
113 | /* From RFC 5869: | ||
114 | * salt - optional salt value (a non-secret random value); | ||
115 | * if not provided, it is set to a string of HashLen zeros. */ | ||
116 | |||
117 | if (xts_len == 0) | ||
118 | { | ||
119 | char zero_salt[dlen]; | ||
120 | memset (zero_salt, 0, dlen); | ||
121 | ret = doHMAC (mac, zero_salt, dlen, skm, skm_len); | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | ret = doHMAC (mac, xts, xts_len, skm, skm_len); | ||
126 | } | ||
108 | if (ret == NULL) | 127 | if (ret == NULL) |
109 | return GNUNET_SYSERR; | 128 | return GNUNET_SYSERR; |
110 | GNUNET_memcpy (prk, ret, gcry_md_get_algo_dlen (gcry_md_get_algo (mac))); | 129 | GNUNET_memcpy (prk, ret, dlen); |
111 | 130 | ||
112 | return GNUNET_YES; | 131 | return GNUNET_YES; |
113 | } | 132 | } |
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 4d3de00bc..f017d1f10 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -310,9 +310,15 @@ GNUNET_CRYPTO_rsa_public_key_encode ( | |||
310 | struct GNUNET_CRYPTO_RsaPublicKeyHeaderP hdr; | 310 | struct GNUNET_CRYPTO_RsaPublicKeyHeaderP hdr; |
311 | int ret; | 311 | int ret; |
312 | 312 | ||
313 | ret = key_from_sexp (ne, key->sexp, "public-key", "ne"); | 313 | ret = key_from_sexp (ne, |
314 | key->sexp, | ||
315 | "public-key", | ||
316 | "ne"); | ||
314 | if (0 != ret) | 317 | if (0 != ret) |
315 | ret = key_from_sexp (ne, key->sexp, "rsa", "ne"); | 318 | ret = key_from_sexp (ne, |
319 | key->sexp, | ||
320 | "rsa", | ||
321 | "ne"); | ||
316 | if (0 != ret) | 322 | if (0 != ret) |
317 | { | 323 | { |
318 | GNUNET_break (0); | 324 | GNUNET_break (0); |
@@ -333,16 +339,25 @@ GNUNET_CRYPTO_rsa_public_key_encode ( | |||
333 | (n_size > UINT16_MAX) ) | 339 | (n_size > UINT16_MAX) ) |
334 | { | 340 | { |
335 | GNUNET_break (0); | 341 | GNUNET_break (0); |
336 | *buffer = NULL; | 342 | if (NULL != buffer) |
343 | *buffer = NULL; | ||
337 | gcry_mpi_release (ne[0]); | 344 | gcry_mpi_release (ne[0]); |
338 | gcry_mpi_release (ne[1]); | 345 | gcry_mpi_release (ne[1]); |
339 | return 0; | 346 | return 0; |
340 | } | 347 | } |
341 | buf_size = n_size + e_size + sizeof (hdr); | 348 | buf_size = n_size + e_size + sizeof (hdr); |
349 | if (NULL == buffer) | ||
350 | { | ||
351 | gcry_mpi_release (ne[0]); | ||
352 | gcry_mpi_release (ne[1]); | ||
353 | return buf_size; | ||
354 | } | ||
342 | buf = GNUNET_malloc (buf_size); | 355 | buf = GNUNET_malloc (buf_size); |
343 | hdr.modulus_length = htons ((uint16_t) n_size); | 356 | hdr.modulus_length = htons ((uint16_t) n_size); |
344 | hdr.public_exponent_length = htons ((uint16_t) e_size); | 357 | hdr.public_exponent_length = htons ((uint16_t) e_size); |
345 | memcpy (buf, &hdr, sizeof (hdr)); | 358 | memcpy (buf, |
359 | &hdr, | ||
360 | sizeof (hdr)); | ||
346 | GNUNET_assert (0 == | 361 | GNUNET_assert (0 == |
347 | gcry_mpi_print (GCRYMPI_FMT_USG, | 362 | gcry_mpi_print (GCRYMPI_FMT_USG, |
348 | (unsigned char *) &buf[sizeof (hdr)], | 363 | (unsigned char *) &buf[sizeof (hdr)], |
diff --git a/src/util/os_installation.c b/src/util/os_installation.c index f15e1871a..171bb5baa 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c | |||
@@ -754,25 +754,9 @@ GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
754 | } | 754 | } |
755 | 755 | ||
756 | 756 | ||
757 | /** | 757 | enum GNUNET_GenericReturnValue |
758 | * Check whether an executable exists and possibly if the suid bit is | ||
759 | * set on the file. Attempts to find the file using the current PATH | ||
760 | * environment variable as a search path. | ||
761 | * | ||
762 | * @param binary the name of the file to check. | ||
763 | * W32: must not have an .exe suffix. | ||
764 | * @param check_suid input true if the binary should be checked for SUID (*nix) | ||
765 | * W32: checks if the program has sufficient privileges by executing this | ||
766 | * binary with the -d flag. -d omits a programs main loop and only | ||
767 | * executes all privileged operations in an binary. | ||
768 | * @param params parameters used for w32 privilege checking (can be NULL for != w32 ) | ||
769 | * @return #GNUNET_YES if the file is SUID (*nix) or can be executed with current privileges (W32), | ||
770 | * #GNUNET_NO if not SUID (but binary exists), | ||
771 | * #GNUNET_SYSERR on error (no such binary or not executable) | ||
772 | */ | ||
773 | int | ||
774 | GNUNET_OS_check_helper_binary (const char *binary, | 758 | GNUNET_OS_check_helper_binary (const char *binary, |
775 | int check_suid, | 759 | bool check_suid, |
776 | const char *params) | 760 | const char *params) |
777 | { | 761 | { |
778 | struct stat statbuf; | 762 | struct stat statbuf; |