From b78d68824e53586eedc08fe9596900f1ffa59f40 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Tue, 29 Jun 1999 01:53:43 +0000 Subject: [PATCH] * enc_helper.c (krb5_encrypt_helper): NULL out the pointer to the ciphertext if there is an error; this prevents stuff farther up from freeing freed memory. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11531 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/ChangeLog | 6 ++++++ src/lib/krb5/krb/enc_helper.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index 77a101ed0..1068b556b 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,9 @@ +1999-06-28 Tom Yu + + * enc_helper.c (krb5_encrypt_helper): NULL out the pointer to the + ciphertext if there is an error; this prevents stuff farther up + from freeing freed memory. + 1999-06-18 Ken Raeburn * init_ctx.c (krb5_free_context): Set field pointers to NULL after diff --git a/src/lib/krb5/krb/enc_helper.c b/src/lib/krb5/krb/enc_helper.c index ff4214937..0e988a08c 100644 --- a/src/lib/krb5/krb/enc_helper.c +++ b/src/lib/krb5/krb/enc_helper.c @@ -44,9 +44,11 @@ krb5_encrypt_helper(context, key, usage, plain, cipher) cipher->ciphertext.length = enclen; if ((cipher->ciphertext.data = (char *) malloc(enclen)) == NULL) return(ret); - - if (ret = krb5_c_encrypt(context, key, usage, 0, plain, cipher)) + ret = krb5_c_encrypt(context, key, usage, 0, plain, cipher); + if (ret) { free(cipher->ciphertext.data); + cipher->ciphertext.data = NULL; + } return(ret); } -- 2.26.2