]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Correct error handling bug in prior commit 617/head
authorGreg Hudson <ghudson@mit.edu>
Thu, 23 Mar 2017 17:42:55 +0000 (13:42 -0400)
committerGreg Hudson <ghudson@mit.edu>
Thu, 23 Mar 2017 17:50:06 +0000 (13:50 -0400)
In crypto_encode_der_cert(), if the second i2d_X509() invocation
fails, make sure to free the allocated pointer and not the
possibly-modified alias.

ticket: 8561

src/plugins/preauth/pkinit/pkinit_crypto_openssl.c

index a1ba9118d02273ac891c85824ba1822752663fa8..be4fc47b151ef3760e1de84cbbe56aeaea3c0ba5 100644 (file)
@@ -6114,10 +6114,10 @@ crypto_encode_der_cert(krb5_context context, pkinit_req_crypto_context reqctx,
     if (len <= 0)
         return EINVAL;
     p = der = malloc(len);
-    if (p == NULL)
+    if (der == NULL)
         return ENOMEM;
     if (i2d_X509(reqctx->received_cert, &p) <= 0) {
-        free(p);
+        free(der);
         return EINVAL;
     }
     *der_out = der;