Skip to content

Commit 2080803

Browse files
fix const mismatch for pointer to data (#974)
See [SSL_get_tlsext_status_ocsp_resp](https://www.openssl.org/docs/man3.0/man3/SSL_get_tlsext_status_ocsp_resp.html) The `resp` argument is not `const`, and when `mongoc-openssl.c` is built on Windows this causes a [C4090](https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4090) error. We can work around this by simply passing a pointer to a pointer that is not const, and then assigning its value to the const pointer.
1 parent 1a62f76 commit 2080803

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libmongoc/src/mongoc/mongoc-openssl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ _mongoc_ocsp_tlsext_status (SSL *ssl, mongoc_openssl_ocsp_opt_t *opts)
775775
X509 *peer = NULL, *issuer = NULL;
776776
STACK_OF (X509) *cert_chain = NULL;
777777
const unsigned char *resp_data = NULL;
778+
unsigned char *mutable_resp_data = NULL;
778779
int cert_status, reason, len, status;
779780
OCSP_CERTID *id = NULL;
780781
ASN1_GENERALIZEDTIME *produced_at = NULL, *this_update = NULL,
@@ -817,7 +818,8 @@ _mongoc_ocsp_tlsext_status (SSL *ssl, mongoc_openssl_ocsp_opt_t *opts)
817818
}
818819

819820
/* Get the stapled OCSP response returned by the server */
820-
len = SSL_get_tlsext_status_ocsp_resp (ssl, &resp_data);
821+
len = SSL_get_tlsext_status_ocsp_resp (ssl, &mutable_resp_data);
822+
resp_data = mutable_resp_data;
821823
stapled_response = !!resp_data;
822824
if (stapled_response) {
823825
/* obtain an OCSP_RESPONSE object from the OCSP response */

0 commit comments

Comments
 (0)