Skip to content

Commit

Permalink
schannel: don't use static to store selected ciphers
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed May 24, 2021
1 parent b03b82a commit bbb7150
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/vtls/schannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ get_alg_id_by_name(char *name)
}

static CURLcode
set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers)
set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers,
int *algIds)
{
char *startCur = ciphers;
int algCount = 0;
static ALG_ID algIds[45]; /*There are 45 listed in the MS headers*/
while(startCur && (0 != *startCur) && (algCount < 45)) {
while(startCur && (0 != *startCur) && (algCount < NUMOF_CIPHERS)) {
long alg = strtol(startCur, 0, 0);
if(!alg)
alg = get_alg_id_by_name(startCur);
Expand Down Expand Up @@ -593,7 +593,8 @@ schannel_connect_step1(struct Curl_easy *data, struct connectdata *conn,
}

if(SSL_CONN_CONFIG(cipher_list)) {
result = set_ssl_ciphers(&schannel_cred, SSL_CONN_CONFIG(cipher_list));
result = set_ssl_ciphers(&schannel_cred, SSL_CONN_CONFIG(cipher_list),
BACKEND->algIds);
if(CURLE_OK != result) {
failf(data, "Unable to set ciphers to passed via SSL_CONN_CONFIG");
return result;
Expand Down
3 changes: 3 additions & 0 deletions lib/vtls/schannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ CURLcode Curl_verify_certificate(struct Curl_easy *data,
#endif
#endif

#define NUMOF_CIPHERS 45 /* There are 45 listed in the MS headers */

struct Curl_schannel_cred {
CredHandle cred_handle;
TimeStamp time_stamp;
Expand Down Expand Up @@ -102,6 +104,7 @@ struct ssl_backend_data {
#ifdef HAS_MANUAL_VERIFY_API
bool use_manual_cred_validation; /* true if manual cred validation is used */
#endif
ALG_ID algIds[NUMOF_CIPHERS];
};
#endif /* EXPOSE_SCHANNEL_INTERNAL_STRUCTS */

Expand Down

0 comments on commit bbb7150

Please sign in to comment.