]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
OCSP_sendreq_bio: Avoid doublefree of mem BIO
authorTomas Mraz <tomas@openssl.org>
Fri, 22 Oct 2021 07:38:18 +0000 (09:38 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 25 Oct 2021 09:43:10 +0000 (11:43 +0200)
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/16886)

crypto/ocsp/ocsp_http.c

index 28166d3a175c7a3e5474589be32af46794ed0ba0..e8b6406d3c384c4604cbf6a81b4e05a23d524315 100644 (file)
@@ -58,13 +58,11 @@ OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req)
     if (ctx == NULL)
         return NULL;
     mem = OSSL_HTTP_REQ_CTX_exchange(ctx);
-    resp = (OCSP_RESPONSE *)
-        ASN1_item_d2i_bio(ASN1_ITEM_rptr(OCSP_RESPONSE), mem, NULL);
-    BIO_free(mem);
+    /* ASN1_item_d2i_bio handles NULL bio gracefully */
+    resp = (OCSP_RESPONSE *)ASN1_item_d2i_bio(ASN1_ITEM_rptr(OCSP_RESPONSE),
+                                              mem, NULL);
 
-    /* this indirectly calls ERR_clear_error(): */
     OSSL_HTTP_REQ_CTX_free(ctx);
-
     return resp;
 }
 #endif /* !defined(OPENSSL_NO_OCSP) */