diff options
author | Greg Hudson <ghudson@mit.edu> | 2013-05-10 14:01:48 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2013-05-14 13:31:41 -0400 |
commit | 6350fd0c909d84c00200885e722cc902049ada05 (patch) | |
tree | a880eae4b875d2b94747048a7092f619c79d33c2 /src/lib/crypto | |
parent | 1799f7b5d9cf4390148248d603d99a3695ddfafe (diff) | |
download | krb5-6350fd0c909d84c00200885e722cc902049ada05.tar.gz krb5-6350fd0c909d84c00200885e722cc902049ada05.tar.xz krb5-6350fd0c909d84c00200885e722cc902049ada05.zip |
Assume mutex locking cannot fail
Locking and unlocking a non-recursive mutex is a simple memory
operation and should not fail on any reasonable platform with correct
usage. A pthread mutex can return EDEADLK on lock or EPERM on unlock,
or EINVAL if the mutex is uninitialized, but all of these conditions
would reflect serious bugs in the calling code.
Change the k5_mutex_lock and k5_mutex_unlock wrappers to return void
and adjust all call sites. Propagate this change through
k5_cc_mutex_lock and k5_cc_mutex_unlock as well.
Diffstat (limited to 'src/lib/crypto')
-rw-r--r-- | src/lib/crypto/krb/prng_fortuna.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/lib/crypto/krb/prng_fortuna.c b/src/lib/crypto/krb/prng_fortuna.c index 8b96a40c92..2a548728ef 100644 --- a/src/lib/crypto/krb/prng_fortuna.c +++ b/src/lib/crypto/krb/prng_fortuna.c @@ -391,9 +391,7 @@ krb5_c_random_add_entropy(krb5_context context, unsigned int randsource, ret = krb5int_crypto_init(); if (ret) return ret; - ret = k5_mutex_lock(&fortuna_lock); - if (ret) - return ret; + k5_mutex_lock(&fortuna_lock); if (randsource == KRB5_C_RANDSOURCE_OSRAND || randsource == KRB5_C_RANDSOURCE_TRUSTEDPARTY) { /* These sources contain enough entropy that we should use them @@ -414,7 +412,6 @@ krb5_c_random_add_entropy(krb5_context context, unsigned int randsource, krb5_error_code KRB5_CALLCONV krb5_c_random_make_octets(krb5_context context, krb5_data *outdata) { - krb5_error_code ret; #ifdef _WIN32 DWORD pid = GetCurrentProcessId(); #else @@ -422,9 +419,7 @@ krb5_c_random_make_octets(krb5_context context, krb5_data *outdata) #endif unsigned char pidbuf[4]; - ret = k5_mutex_lock(&fortuna_lock); - if (ret) - return ret; + k5_mutex_lock(&fortuna_lock); if (!have_entropy) { k5_mutex_unlock(&fortuna_lock); |