Ensure valid key in krb5int_yarrow_cipher_encrypt_block
authorEzra Peisach <epeisach@mit.edu>
Sat, 4 Sep 2010 21:46:53 +0000 (21:46 +0000)
committerEzra Peisach <epeisach@mit.edu>
Sat, 4 Sep 2010 21:46:53 +0000 (21:46 +0000)
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

index 7222d94c5de18af1a515ea286bcfe28e25de8f10..8a664ac31426702456b8a2818971894d9518496c 100644 (file)
@@ -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);