Commit b3003ff1ec for openssl.org
commit b3003ff1ecac4118d5779f4917c684d83c9c091a
Author: Nikola Pajkovsky <nikolap@openssl.org>
Date: Tue May 19 09:36:49 2026 +0200
fix function pointer type mismatch in OCSP_REQUEST/RESPONSE bio macros
d2i_OCSP_REQUEST/d2i_OCSP_RESPONSE are declared with type-specific
signatures returning OCSP_REQUEST*/OCSP_RESPONSE*, but the
d2i_OCSP_{REQUEST,RESPONSE}_bio macros routed them through
ASN1_d2i_bio_of -> ASN1_d2i_bio, which calls them via a
d2i_of_void* pointer:
void *(*)(void **, const unsigned char **, long)
The analogous i2d_OCSP_{REQUEST,RESPONSE}_bio macros did the same
through ASN1_i2d_bio_of -> ASN1_i2d_bio with i2d_of_void*.
Rewrite the macros to dispatch through
ASN1_item_d2i_bio/ASN1_item_i2d_bio with ASN1_ITEM_rptr(OCSP_*)
directly. This eliminates the function-pointer cast entirely; both old
and new paths bottom out in the same ASN1_item_d2i_ex / ASN1_item_i2d
call, so behavior is identical.
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Milan Broz <mbroz@openssl.org>
MergeDate: Thu Jun 25 12:12:50 2026
(Merged from https://github.com/openssl/openssl/pull/31523)
diff --git a/include/openssl/ocsp.h.in b/include/openssl/ocsp.h.in
index 86ed7f5869..ce33a4d8fc 100644
--- a/include/openssl/ocsp.h.in
+++ b/include/openssl/ocsp.h.in
@@ -144,9 +144,13 @@ typedef struct ocsp_service_locator_st OCSP_SERVICELOC;
#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST"
#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
-#define d2i_OCSP_REQUEST_bio(bp, p) ASN1_d2i_bio_of(OCSP_REQUEST, OCSP_REQUEST_new, d2i_OCSP_REQUEST, bp, p)
+#define d2i_OCSP_REQUEST_bio(bp, p) \
+ ((OCSP_REQUEST *)ASN1_item_d2i_bio(ASN1_ITEM_rptr(OCSP_REQUEST), \
+ (bp), CHECKED_PPTR_OF(OCSP_REQUEST, p)))
-#define d2i_OCSP_RESPONSE_bio(bp, p) ASN1_d2i_bio_of(OCSP_RESPONSE, OCSP_RESPONSE_new, d2i_OCSP_RESPONSE, bp, p)
+#define d2i_OCSP_RESPONSE_bio(bp, p) \
+ ((OCSP_RESPONSE *)ASN1_item_d2i_bio(ASN1_ITEM_rptr(OCSP_RESPONSE), \
+ (bp), CHECKED_PPTR_OF(OCSP_RESPONSE, p)))
#define PEM_read_bio_OCSP_REQUEST(bp, x, cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
(d2i_of_void *)d2i_OCSP_REQUEST, PEM_STRING_OCSP_REQUEST, \
@@ -164,9 +168,13 @@ typedef struct ocsp_service_locator_st OCSP_SERVICELOC;
PEM_ASN1_write_bio((i2d_of_void *)i2d_OCSP_RESPONSE, PEM_STRING_OCSP_RESPONSE, \
bp, (char *)(o), NULL, NULL, 0, NULL, NULL)
-#define i2d_OCSP_RESPONSE_bio(bp, o) ASN1_i2d_bio_of(OCSP_RESPONSE, i2d_OCSP_RESPONSE, bp, o)
+#define i2d_OCSP_RESPONSE_bio(bp, o) \
+ ASN1_item_i2d_bio(ASN1_ITEM_rptr(OCSP_RESPONSE), \
+ (bp), CHECKED_PTR_OF(const OCSP_RESPONSE, o))
-#define i2d_OCSP_REQUEST_bio(bp, o) ASN1_i2d_bio_of(OCSP_REQUEST, i2d_OCSP_REQUEST, bp, o)
+#define i2d_OCSP_REQUEST_bio(bp, o) \
+ ASN1_item_i2d_bio(ASN1_ITEM_rptr(OCSP_REQUEST), \
+ (bp), CHECKED_PTR_OF(const OCSP_REQUEST, o))
#define ASN1_BIT_STRING_digest(data, type, md, len) \
ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING), type, data, md, len)