From: Ezra Peisach Date: Fri, 6 Nov 1998 15:04:02 +0000 (+0000) Subject: * k5unseal.c (kg2_unwrap_integ): Handle case of malloc(0) X-Git-Tag: krb5-1.1-beta1~498 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=71ad65c74a2d5caab7634b122b7fbd8b6df26f57;p=krb5.git * k5unseal.c (kg2_unwrap_integ): Handle case of malloc(0) returning NULL. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11018 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index e12dfdb2b..7145cb46e 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 6 09:19:23 1998 Ezra Peisach + + * k5unseal.c (kg2_unwrap_integ): Handle case of malloc(0) + returning NULL. + 1998-10-27 Marc Horowitz * Makefile.in, accept_sec_context.c, acquire_cred.c, canon_name.c, diff --git a/src/lib/gssapi/krb5/k5unseal.c b/src/lib/gssapi/krb5/k5unseal.c index c32e3255d..64a95396b 100644 --- a/src/lib/gssapi/krb5/k5unseal.c +++ b/src/lib/gssapi/krb5/k5unseal.c @@ -287,14 +287,15 @@ kg2_unwrap_integ(context, minor_status, ctx, ptr, bodysize, output, qop_state) return(retval); } - if ((output->value = (void *) malloc(tmsglen)) == NULL) { - *minor_status = ENOMEM; - return(GSS_S_FAILURE); + if (tmsglen) { + if ((output->value = (void *) malloc(tmsglen)) == NULL) { + *minor_status = ENOMEM; + return(GSS_S_FAILURE); + } + memcpy(output->value, tmsg, tmsglen); + output->length = tmsglen; } - memcpy(output->value, tmsg, tmsglen); - output->length = tmsglen; - if (qop_state) *qop_state = GSS_C_QOP_DEFAULT; @@ -420,15 +421,16 @@ kg2_unwrap_priv(context, minor_status, ctx, ptr, bodysize, output, qop_state) tmsg = ptr; - if ((output->value = (void *) malloc(tmsglen)) == NULL) { - free(plain.data); - *minor_status = ENOMEM; - return(GSS_S_FAILURE); + if (tmsglen) { + if ((output->value = (void *) malloc(tmsglen)) == NULL) { + free(plain.data); + *minor_status = ENOMEM; + return(GSS_S_FAILURE); + } + memcpy(output->value, tmsg, tmsglen); + output->length = tmsglen; } - memcpy(output->value, tmsg, tmsglen); - output->length = tmsglen; - if (qop_state) *qop_state = GSS_C_QOP_DEFAULT;