diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-01-04 17:05:05 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-01-04 17:05:05 +0100 |
commit | f46c107278b96264b2e5302b4ebb050f73abf869 (patch) | |
tree | f2bd74b81fa33546e513b2eabf7a790eb3b631e8 /src | |
parent | e20eca334a33b8340524a8fa6ad1d6b606e1dd0c (diff) | |
download | gnunet-f46c107278b96264b2e5302b4ebb050f73abf869.tar.gz gnunet-f46c107278b96264b2e5302b4ebb050f73abf869.zip |
trying again to fix test_service timeout on v6 failure
Diffstat (limited to 'src')
-rw-r--r-- | src/util/crypto_ecc.c | 4 | ||||
-rw-r--r-- | src/util/crypto_ecc_dlog.c | 1 | ||||
-rw-r--r-- | src/util/crypto_ecc_setup.c | 98 | ||||
-rw-r--r-- | src/util/crypto_hash_file.c | 16 | ||||
-rw-r--r-- | src/util/test_service.c | 12 |
5 files changed, 95 insertions, 36 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index 7845932ee..5d5e8a9ce 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -1242,7 +1242,7 @@ eddsa_d_to_a (gcry_mpi_t d) | |||
1242 | size_t rawmpilen; | 1242 | size_t rawmpilen; |
1243 | unsigned char digest[64]; /* 512-bit hash value */ | 1243 | unsigned char digest[64]; /* 512-bit hash value */ |
1244 | gcry_buffer_t hvec[2]; | 1244 | gcry_buffer_t hvec[2]; |
1245 | int b; | 1245 | unsigned int b; |
1246 | gcry_mpi_t a; | 1246 | gcry_mpi_t a; |
1247 | 1247 | ||
1248 | b = 256 / 8; /* number of bytes in `d` */ | 1248 | b = 256 / 8; /* number of bytes in `d` */ |
@@ -1257,7 +1257,7 @@ eddsa_d_to_a (gcry_mpi_t d) | |||
1257 | d)); | 1257 | d)); |
1258 | hvec[0].data = digest; | 1258 | hvec[0].data = digest; |
1259 | hvec[0].off = 0; | 1259 | hvec[0].off = 0; |
1260 | hvec[0].len = b > rawmpilen? b - rawmpilen : 0; | 1260 | hvec[0].len = b > rawmpilen ? (b - rawmpilen) : 0; |
1261 | hvec[1].data = rawmpi; | 1261 | hvec[1].data = rawmpi; |
1262 | hvec[1].off = 0; | 1262 | hvec[1].off = 0; |
1263 | hvec[1].len = rawmpilen; | 1263 | hvec[1].len = rawmpilen; |
diff --git a/src/util/crypto_ecc_dlog.c b/src/util/crypto_ecc_dlog.c index 38e2088cc..91411368f 100644 --- a/src/util/crypto_ecc_dlog.c +++ b/src/util/crypto_ecc_dlog.c | |||
@@ -130,6 +130,7 @@ GNUNET_CRYPTO_ecc_bin_to_point (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
130 | gcry_ctx_t ctx; | 130 | gcry_ctx_t ctx; |
131 | gcry_mpi_point_t q; | 131 | gcry_mpi_point_t q; |
132 | 132 | ||
133 | (void) edc; | ||
133 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, | 134 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, |
134 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 135 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
135 | (int) sizeof (bin->q_y), | 136 | (int) sizeof (bin->q_y), |
diff --git a/src/util/crypto_ecc_setup.c b/src/util/crypto_ecc_setup.c index 64610ddd3..e7caf9ded 100644 --- a/src/util/crypto_ecc_setup.c +++ b/src/util/crypto_ecc_setup.c | |||
@@ -80,6 +80,7 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename) | |||
80 | unsigned int cnt; | 80 | unsigned int cnt; |
81 | int ec; | 81 | int ec; |
82 | uint64_t fs; | 82 | uint64_t fs; |
83 | ssize_t sret; | ||
83 | 84 | ||
84 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename)) | 85 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename)) |
85 | return NULL; | 86 | return NULL; |
@@ -193,7 +194,8 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename) | |||
193 | { | 194 | { |
194 | LOG (GNUNET_ERROR_TYPE_ERROR, | 195 | LOG (GNUNET_ERROR_TYPE_ERROR, |
195 | _("When trying to read key file `%s' I found %u bytes but I need at least %u.\n"), | 196 | _("When trying to read key file `%s' I found %u bytes but I need at least %u.\n"), |
196 | filename, (unsigned int) fs, | 197 | filename, |
198 | (unsigned int) fs, | ||
197 | (unsigned int) sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)); | 199 | (unsigned int) sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)); |
198 | LOG (GNUNET_ERROR_TYPE_ERROR, | 200 | LOG (GNUNET_ERROR_TYPE_ERROR, |
199 | _("This may be ok if someone is currently generating a key.\n")); | 201 | _("This may be ok if someone is currently generating a key.\n")); |
@@ -205,12 +207,20 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename) | |||
205 | } | 207 | } |
206 | fs = sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey); | 208 | fs = sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey); |
207 | priv = GNUNET_malloc (fs); | 209 | priv = GNUNET_malloc (fs); |
208 | GNUNET_assert (fs == GNUNET_DISK_file_read (fd, priv, fs)); | 210 | sret = GNUNET_DISK_file_read (fd, |
211 | priv, | ||
212 | fs); | ||
213 | GNUNET_assert ( (sret >= 0) && | ||
214 | (fs == (size_t) sret) ); | ||
209 | if (GNUNET_YES != | 215 | if (GNUNET_YES != |
210 | GNUNET_DISK_file_unlock (fd, 0, | 216 | GNUNET_DISK_file_unlock (fd, |
217 | 0, | ||
211 | sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey))) | 218 | sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey))) |
212 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); | 219 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
213 | GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); | 220 | "fcntl", |
221 | filename); | ||
222 | GNUNET_assert (GNUNET_YES == | ||
223 | GNUNET_DISK_file_close (fd)); | ||
214 | return priv; | 224 | return priv; |
215 | } | 225 | } |
216 | 226 | ||
@@ -237,8 +247,10 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename) | |||
237 | unsigned int cnt; | 247 | unsigned int cnt; |
238 | int ec; | 248 | int ec; |
239 | uint64_t fs; | 249 | uint64_t fs; |
240 | 250 | ssize_t sret; | |
241 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename)) | 251 | |
252 | if (GNUNET_SYSERR == | ||
253 | GNUNET_DISK_directory_create_for_file (filename)) | ||
242 | return NULL; | 254 | return NULL; |
243 | while (GNUNET_YES != GNUNET_DISK_file_test (filename)) | 255 | while (GNUNET_YES != GNUNET_DISK_file_test (filename)) |
244 | { | 256 | { |
@@ -255,19 +267,24 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename) | |||
255 | { | 267 | { |
256 | /* must exist but not be accessible, fail for good! */ | 268 | /* must exist but not be accessible, fail for good! */ |
257 | if (0 != ACCESS (filename, R_OK)) | 269 | if (0 != ACCESS (filename, R_OK)) |
258 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", filename); | 270 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, |
271 | "access", | ||
272 | filename); | ||
259 | else | 273 | else |
260 | GNUNET_break (0); /* what is going on!? */ | 274 | GNUNET_break (0); /* what is going on!? */ |
261 | return NULL; | 275 | return NULL; |
262 | } | 276 | } |
263 | continue; | 277 | continue; |
264 | } | 278 | } |
265 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename); | 279 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, |
280 | "open", | ||
281 | filename); | ||
266 | return NULL; | 282 | return NULL; |
267 | } | 283 | } |
268 | cnt = 0; | 284 | cnt = 0; |
269 | while (GNUNET_YES != | 285 | while (GNUNET_YES != |
270 | GNUNET_DISK_file_lock (fd, 0, | 286 | GNUNET_DISK_file_lock (fd, |
287 | 0, | ||
271 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), | 288 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), |
272 | GNUNET_YES)) | 289 | GNUNET_YES)) |
273 | { | 290 | { |
@@ -276,7 +293,8 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename) | |||
276 | { | 293 | { |
277 | ec = errno; | 294 | ec = errno; |
278 | LOG (GNUNET_ERROR_TYPE_ERROR, | 295 | LOG (GNUNET_ERROR_TYPE_ERROR, |
279 | _("Could not acquire lock on file `%s': %s...\n"), filename, | 296 | _("Could not acquire lock on file `%s': %s...\n"), |
297 | filename, | ||
280 | STRERROR (ec)); | 298 | STRERROR (ec)); |
281 | } | 299 | } |
282 | } | 300 | } |
@@ -285,21 +303,29 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename) | |||
285 | priv = GNUNET_CRYPTO_ecdsa_key_create (); | 303 | priv = GNUNET_CRYPTO_ecdsa_key_create (); |
286 | GNUNET_assert (NULL != priv); | 304 | GNUNET_assert (NULL != priv); |
287 | GNUNET_assert (sizeof (*priv) == | 305 | GNUNET_assert (sizeof (*priv) == |
288 | GNUNET_DISK_file_write (fd, priv, sizeof (*priv))); | 306 | GNUNET_DISK_file_write (fd, |
307 | priv, | ||
308 | sizeof (*priv))); | ||
289 | GNUNET_DISK_file_sync (fd); | 309 | GNUNET_DISK_file_sync (fd); |
290 | if (GNUNET_YES != | 310 | if (GNUNET_YES != |
291 | GNUNET_DISK_file_unlock (fd, 0, | 311 | GNUNET_DISK_file_unlock (fd, 0, |
292 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 312 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) |
293 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); | 313 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
294 | GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); | 314 | "fcntl", |
315 | filename); | ||
316 | GNUNET_assert (GNUNET_YES == | ||
317 | GNUNET_DISK_file_close (fd)); | ||
295 | return priv; | 318 | return priv; |
296 | } | 319 | } |
297 | /* key file exists already, read it! */ | 320 | /* key file exists already, read it! */ |
298 | fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, | 321 | fd = GNUNET_DISK_file_open (filename, |
322 | GNUNET_DISK_OPEN_READ, | ||
299 | GNUNET_DISK_PERM_NONE); | 323 | GNUNET_DISK_PERM_NONE); |
300 | if (NULL == fd) | 324 | if (NULL == fd) |
301 | { | 325 | { |
302 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename); | 326 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, |
327 | "open", | ||
328 | filename); | ||
303 | return NULL; | 329 | return NULL; |
304 | } | 330 | } |
305 | cnt = 0; | 331 | cnt = 0; |
@@ -318,25 +344,34 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename) | |||
318 | filename, | 344 | filename, |
319 | STRERROR (ec)); | 345 | STRERROR (ec)); |
320 | LOG (GNUNET_ERROR_TYPE_ERROR, | 346 | LOG (GNUNET_ERROR_TYPE_ERROR, |
321 | _ | 347 | _("This may be ok if someone is currently generating a private key.\n")); |
322 | ("This may be ok if someone is currently generating a private key.\n")); | ||
323 | } | 348 | } |
324 | short_wait (); | 349 | short_wait (); |
325 | continue; | 350 | continue; |
326 | } | 351 | } |
327 | if (GNUNET_YES != GNUNET_DISK_file_test (filename)) | 352 | if (GNUNET_YES != |
353 | GNUNET_DISK_file_test (filename)) | ||
328 | { | 354 | { |
329 | /* eh, what!? File we opened is now gone!? */ | 355 | /* eh, what!? File we opened is now gone!? */ |
330 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", filename); | 356 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
357 | "stat", | ||
358 | filename); | ||
331 | if (GNUNET_YES != | 359 | if (GNUNET_YES != |
332 | GNUNET_DISK_file_unlock (fd, 0, | 360 | GNUNET_DISK_file_unlock (fd, 0, |
333 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 361 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) |
334 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); | 362 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
335 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); | 363 | "fcntl", |
364 | filename); | ||
365 | GNUNET_assert (GNUNET_OK == | ||
366 | GNUNET_DISK_file_close (fd)); | ||
336 | 367 | ||
337 | return NULL; | 368 | return NULL; |
338 | } | 369 | } |
339 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) | 370 | if (GNUNET_OK != |
371 | GNUNET_DISK_file_size (filename, | ||
372 | &fs, | ||
373 | GNUNET_YES, | ||
374 | GNUNET_YES)) | ||
340 | fs = 0; | 375 | fs = 0; |
341 | if (fs < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)) | 376 | if (fs < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)) |
342 | { | 377 | { |
@@ -345,7 +380,9 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename) | |||
345 | if (GNUNET_YES != | 380 | if (GNUNET_YES != |
346 | GNUNET_DISK_file_unlock (fd, 0, | 381 | GNUNET_DISK_file_unlock (fd, 0, |
347 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 382 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) |
348 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); | 383 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
384 | "fcntl", | ||
385 | filename); | ||
349 | if (0 == ++cnt % 10) | 386 | if (0 == ++cnt % 10) |
350 | { | 387 | { |
351 | LOG (GNUNET_ERROR_TYPE_ERROR, | 388 | LOG (GNUNET_ERROR_TYPE_ERROR, |
@@ -362,12 +399,19 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename) | |||
362 | } | 399 | } |
363 | fs = sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey); | 400 | fs = sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey); |
364 | priv = GNUNET_malloc (fs); | 401 | priv = GNUNET_malloc (fs); |
365 | GNUNET_assert (fs == GNUNET_DISK_file_read (fd, priv, fs)); | 402 | sret = GNUNET_DISK_file_read (fd, |
403 | priv, | ||
404 | fs); | ||
405 | GNUNET_assert ( (sret >= 0) && | ||
406 | (fs == (size_t) sret) ); | ||
366 | if (GNUNET_YES != | 407 | if (GNUNET_YES != |
367 | GNUNET_DISK_file_unlock (fd, 0, | 408 | GNUNET_DISK_file_unlock (fd, 0, |
368 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 409 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) |
369 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); | 410 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
370 | GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); | 411 | "fcntl", |
412 | filename); | ||
413 | GNUNET_assert (GNUNET_YES == | ||
414 | GNUNET_DISK_file_close (fd)); | ||
371 | return priv; | 415 | return priv; |
372 | } | 416 | } |
373 | 417 | ||
diff --git a/src/util/crypto_hash_file.c b/src/util/crypto_hash_file.c index 3e5900200..cb632d02c 100644 --- a/src/util/crypto_hash_file.c +++ b/src/util/crypto_hash_file.c | |||
@@ -124,23 +124,29 @@ file_hash_task (void *cls) | |||
124 | struct GNUNET_CRYPTO_FileHashContext *fhc = cls; | 124 | struct GNUNET_CRYPTO_FileHashContext *fhc = cls; |
125 | struct GNUNET_HashCode *res; | 125 | struct GNUNET_HashCode *res; |
126 | size_t delta; | 126 | size_t delta; |
127 | ssize_t sret; | ||
127 | 128 | ||
128 | fhc->task = NULL; | 129 | fhc->task = NULL; |
129 | GNUNET_assert (fhc->offset <= fhc->fsize); | 130 | GNUNET_assert (fhc->offset <= fhc->fsize); |
130 | delta = fhc->bsize; | 131 | delta = fhc->bsize; |
131 | if (fhc->fsize - fhc->offset < delta) | 132 | if (fhc->fsize - fhc->offset < delta) |
132 | delta = fhc->fsize - fhc->offset; | 133 | delta = fhc->fsize - fhc->offset; |
133 | if (delta != GNUNET_DISK_file_read (fhc->fh, | 134 | sret = GNUNET_DISK_file_read (fhc->fh, |
134 | fhc->buffer, | 135 | fhc->buffer, |
135 | delta)) | 136 | delta); |
137 | if ( (sret < 0) || | ||
138 | (delta != (size_t) sret) ) | ||
136 | { | 139 | { |
137 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, | 140 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
138 | "read", | 141 | "read", |
139 | fhc->filename); | 142 | fhc->filename); |
140 | file_hash_finish (fhc, NULL); | 143 | file_hash_finish (fhc, |
144 | NULL); | ||
141 | return; | 145 | return; |
142 | } | 146 | } |
143 | gcry_md_write (fhc->md, fhc->buffer, delta); | 147 | gcry_md_write (fhc->md, |
148 | fhc->buffer, | ||
149 | delta); | ||
144 | fhc->offset += delta; | 150 | fhc->offset += delta; |
145 | if (fhc->offset == fhc->fsize) | 151 | if (fhc->offset == fhc->fsize) |
146 | { | 152 | { |
diff --git a/src/util/test_service.c b/src/util/test_service.c index 3ffacb0a9..424a445bb 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -52,8 +52,11 @@ handle_recv (void *cls, | |||
52 | "Received client message...\n"); | 52 | "Received client message...\n"); |
53 | GNUNET_SERVICE_client_continue (client); | 53 | GNUNET_SERVICE_client_continue (client); |
54 | global_ret = 2; | 54 | global_ret = 2; |
55 | GNUNET_MQ_destroy (mq); | 55 | if (NULL != mq) |
56 | mq = NULL; | 56 | { |
57 | GNUNET_MQ_destroy (mq); | ||
58 | mq = NULL; | ||
59 | } | ||
57 | } | 60 | } |
58 | 61 | ||
59 | 62 | ||
@@ -106,6 +109,11 @@ static void | |||
106 | timeout_task (void *cls) | 109 | timeout_task (void *cls) |
107 | { | 110 | { |
108 | tt = NULL; | 111 | tt = NULL; |
112 | if (NULL != mq) | ||
113 | { | ||
114 | GNUNET_MQ_destroy (mq); | ||
115 | mq = NULL; | ||
116 | } | ||
109 | global_ret = 33; | 117 | global_ret = 33; |
110 | GNUNET_SCHEDULER_shutdown (); | 118 | GNUNET_SCHEDULER_shutdown (); |
111 | } | 119 | } |