From 97b6d19bc89c8eb6754225875890e0f2dbdd929d Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Sat, 4 Sep 2010 21:46:53 +0000 Subject: [PATCH] Ensure valid key in krb5int_yarrow_cipher_encrypt_block Under low memory conditions (or when testing memory allocation failures), the key pointer will be 0 - and not initialized. Test and return failure before deref a NULL. ticket: 6772 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24292 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/krb/yarrow/ycipher.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/crypto/krb/yarrow/ycipher.c b/src/lib/crypto/krb/yarrow/ycipher.c index 7222d94c5..8a664ac31 100644 --- a/src/lib/crypto/krb/yarrow/ycipher.c +++ b/src/lib/crypto/krb/yarrow/ycipher.c @@ -74,6 +74,12 @@ int krb5int_yarrow_cipher_encrypt_block(CIPHER_CTX *ctx, krb5_crypto_iov iov; const struct krb5_enc_provider *enc = &yarrow_enc_provider; + /* + This can happen if ENOMEM in initializing the key + which happens on init or during reseeding + */ + if (!ctx->key) + return YARROW_FAIL; memcpy(out, in, CIPHER_BLOCK_SIZE); iov.flags = KRB5_CRYPTO_TYPE_DATA; iov.data = make_data(out, CIPHER_BLOCK_SIZE); -- 2.26.2