Skip to content

Commit 6caae14

Browse files
committed
Fix bug with paCred
1 parent de015f3 commit 6caae14

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel-private.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <schannel.h>
3333
#include <security.h>
3434

35-
3635
BSON_BEGIN_DECLS
3736

3837

@@ -62,7 +61,7 @@ typedef struct {
6261
typedef struct _mongoc_secure_channel_cred {
6362
PCCERT_CONTEXT cert; /* Owning. Optional client cert. */
6463
schannel_credential_type cred_type;
65-
void *cred; /* Underlying type is specified by type. */
64+
void *cred; /* Underlying type is specified by schannel_credential_type. */
6665
} mongoc_secure_channel_cred;
6766

6867
typedef struct {

src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ _mongoc_stream_tls_secure_channel_should_retry(mongoc_stream_t *stream)
852852
#ifdef MONGOC_HAVE_SCH_CREDENTIALS
853853

854854
void *
855-
_mongoc_secure_channel_sch_credentials_new(const mongoc_ssl_opt_t *opt, PCCERT_CONTEXT cert, DWORD enabled_protocols)
855+
_mongoc_secure_channel_sch_credentials_new(const mongoc_ssl_opt_t *opt, PCCERT_CONTEXT *cert, DWORD enabled_protocols)
856856
{
857857
SCH_CREDENTIALS *cred = bson_malloc0(sizeof(SCH_CREDENTIALS));
858858

@@ -889,7 +889,7 @@ _mongoc_secure_channel_sch_credentials_new(const mongoc_ssl_opt_t *opt, PCCERT_C
889889

890890
if (cert) {
891891
cred->cCreds = 1;
892-
cred->paCred = &cert;
892+
cred->paCred = cert;
893893
}
894894

895895
TLS_PARAMETERS tls_parameters;
@@ -909,7 +909,7 @@ _mongoc_secure_channel_sch_credentials_new(const mongoc_ssl_opt_t *opt, PCCERT_C
909909
#endif
910910

911911
void *
912-
_mongoc_secure_channel_schannel_cred_new(const mongoc_ssl_opt_t *opt, PCCERT_CONTEXT cert, DWORD enabled_protocols)
912+
_mongoc_secure_channel_schannel_cred_new(const mongoc_ssl_opt_t *opt, PCCERT_CONTEXT *cert, DWORD enabled_protocols)
913913
{
914914
SCHANNEL_CRED *cred = bson_malloc0(sizeof(SCHANNEL_CRED));
915915

@@ -945,7 +945,7 @@ _mongoc_secure_channel_schannel_cred_new(const mongoc_ssl_opt_t *opt, PCCERT_CON
945945

946946
if (cert) {
947947
cred->cCreds = 1;
948-
cred->paCred = &cert;
948+
cred->paCred = cert;
949949
}
950950

951951
cred->grbitEnabledProtocols = enabled_protocols;
@@ -985,18 +985,15 @@ mongoc_secure_channel_cred_new(const mongoc_ssl_opt_t *opt)
985985
#ifdef MONGOC_HAVE_SCH_CREDENTIALS
986986
// SCH_CREDENTIALS is supported in Windows 10 1809 / Server 1809 and later
987987
if (_mongoc_verify_windows_version(10, 0, 17763, false)) {
988-
cred->cred = _mongoc_secure_channel_sch_credentials_new(opt, cred->cert, enabled_protocols);
988+
cred->cred = _mongoc_secure_channel_sch_credentials_new(opt, &cred->cert, enabled_protocols);
989989
cred->cred_type = sch_credentials;
990-
printf("Using SCH_CREDENTIALS\n");
991990
} else {
992-
cred->cred = _mongoc_secure_channel_schannel_cred_new(opt, cred->cert, enabled_protocols);
991+
cred->cred = _mongoc_secure_channel_schannel_cred_new(opt, &cred->cert, enabled_protocols);
993992
cred->cred_type = schannel_cred;
994-
printf("Using SCHANNEL_CREDS\n");
995993
}
996994
#else
997-
cred->cred = _mongoc_secure_channel_schannel_cred_new(opt, cred->cert, enabled_protocols);
995+
cred->cred = _mongoc_secure_channel_schannel_cred_new(opt, &cred->cert, enabled_protocols);
998996
cred->cred_type = schannel_cred;
999-
printf("Using SCHANNEL_CREDS\n");
1000997
#endif
1001998

1002999
return cred;
@@ -1097,7 +1094,6 @@ mongoc_stream_tls_secure_channel_new_with_creds(mongoc_stream_t *base_stream,
10971094
// Cast signed SECURITY_STATUS to unsigned DWORD. FormatMessage expects DWORD.
10981095
char *msg = mongoc_winerr_to_string((DWORD)sspi_status);
10991096
MONGOC_ERROR("Failed to initialize security context: %s", msg);
1100-
printf("Failed to initialize security context: %s\n", msg);
11011097
bson_free(msg);
11021098
// Detach the base stream so caller can free.
11031099
tls->base_stream = NULL;

0 commit comments

Comments
 (0)