fix leak of old keystate if loading of new keystate failed

This commit is contained in:
Christian Grothoff 2020-03-29 01:58:27 +01:00
parent 0f5f27e853
commit 937065ae9f
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -986,6 +986,11 @@ reload_keys_sign_iter (
now.abs_value_us) ) now.abs_value_us) )
{ {
/* We use the most recent one, if it is valid now (not just in the near future) */ /* We use the most recent one, if it is valid now (not just in the near future) */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found signing key valid until `%s'\n",
GNUNET_STRINGS_absolute_time_to_string (
GNUNET_TIME_absolute_ntoh (
key_state->current_sign_key_issue.issue.end)));
key_state->current_sign_key_issue = *ski; key_state->current_sign_key_issue = *ski;
} }
if (0 != if (0 !=
@ -1965,10 +1970,12 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now,
} }
if (NULL == internal_key_state) if (NULL == internal_key_state)
{ {
/* We tried and failed (again) to setup #internal_key_state */ /* We tried and failed to setup #internal_key_state */
GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex)); GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex));
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to initialize key state\n"); "Failed to initialize key state\n");
if (NULL != os)
ks_free (os);
return NULL; return NULL;
} }
key_state = internal_key_state; key_state = internal_key_state;