* k5unseal.c (kg2_unwrap_integ): Handle case of malloc(0)
authorEzra Peisach <epeisach@mit.edu>
Fri, 6 Nov 1998 15:04:02 +0000 (15:04 +0000)
committerEzra Peisach <epeisach@mit.edu>
Fri, 6 Nov 1998 15:04:02 +0000 (15:04 +0000)
returning NULL.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11018 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/krb5/ChangeLog
src/lib/gssapi/krb5/k5unseal.c

index e12dfdb2b3fcdfee98da62621196bd3fa1a12572..7145cb46e5673a59d16ffede0f7cc0912d8c52e2 100644 (file)
@@ -1,3 +1,8 @@
+Fri Nov  6 09:19:23 1998  Ezra Peisach  <epeisach@mit.edu>
+
+       * k5unseal.c (kg2_unwrap_integ): Handle case of malloc(0)
+       returning NULL.
+
 1998-10-27  Marc Horowitz  <marc@mit.edu>
 
        * Makefile.in, accept_sec_context.c, acquire_cred.c, canon_name.c,
index c32e3255d5f436eb50f0ecba9505d9f811e08fa3..64a95396bf8840eb555edfd7a882b01908f02c38 100644 (file)
@@ -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;