http_client.c: Prevent spurious error queue entry on NULL mem argument
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Mon, 8 Mar 2021 08:25:54 +0000 (09:25 +0100)
committerDr. David von Oheimb <dev@ddvo.net>
Wed, 31 Mar 2021 17:53:05 +0000 (19:53 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14630)

crypto/http/http_client.c

index 8e4f8e8c83bd4ce3b3c37c9b61acb5cfdd5b188e..eec13973fb75a2d73797af18f790ebe31a700420 100644 (file)
@@ -734,13 +734,12 @@ static BIO *HTTP_new_bio(const char *server /* optionally includes ":port" */,
 static ASN1_VALUE *BIO_mem_d2i(BIO *mem, const ASN1_ITEM *it)
 {
     const unsigned char *p;
-    long len = BIO_get_mem_data(mem, &p);
     ASN1_VALUE *resp;
 
     if (mem == NULL)
         return NULL;
 
-    if ((resp = ASN1_item_d2i(NULL, &p, len, it)) == NULL)
+    if ((resp = ASN1_item_d2i(NULL, &p, BIO_get_mem_data(mem, &p), it)) == NULL)
         ERR_raise(ERR_LIB_HTTP, HTTP_R_RESPONSE_PARSE_ERROR);
     return resp;
 }