|
| 1 | +From 0aa2cd8539608511e34a58473f2974ae0ae50444 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Matthew John Cheetham <mjcheetham@outlook.com> |
| 3 | +Date: Tue, 24 Mar 2026 11:53:02 +0000 |
| 4 | +Subject: [PATCH 3/4] auth: upgrade SSPI identity to SEC_WINNT_AUTH_IDENTITY_EX |
| 5 | + |
| 6 | +Replace SEC_WINNT_AUTH_IDENTITY with SEC_WINNT_AUTH_IDENTITY_EX across all |
| 7 | +SSPI authentication code. The extended structure adds Version, Length, and |
| 8 | +PackageList fields while remaining backwards compatible with all SSPI |
| 9 | +functions. Available since Windows XP. |
| 10 | + |
| 11 | +Curl_create_sspi_identity now sets the Version and Length fields when |
| 12 | +initializing the structure. |
| 13 | + |
| 14 | +Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com> |
| 15 | +Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> |
| 16 | +--- |
| 17 | + lib/curl_sspi.c | 6 ++++-- |
| 18 | + lib/curl_sspi.h | 6 +++--- |
| 19 | + lib/ldap.c | 2 +- |
| 20 | + lib/vauth/digest_sspi.c | 10 +++++----- |
| 21 | + lib/vauth/vauth.h | 12 ++++++------ |
| 22 | + 5 files changed, 19 insertions(+), 17 deletions(-) |
| 23 | + |
| 24 | +diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c |
| 25 | +index 1d4cf925d6..018bfff28e 100644 |
| 26 | +--- a/lib/curl_sspi.c |
| 27 | ++++ b/lib/curl_sspi.c |
| 28 | +@@ -93,7 +93,7 @@ void Curl_sspi_global_cleanup(void) |
| 29 | + * Returns CURLE_OK on success. |
| 30 | + */ |
| 31 | + CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, |
| 32 | +- SEC_WINNT_AUTH_IDENTITY *identity) |
| 33 | ++ SEC_WINNT_AUTH_IDENTITY_EX *identity) |
| 34 | + { |
| 35 | + xcharp_u useranddomain; |
| 36 | + xcharp_u user, dup_user; |
| 37 | +@@ -105,6 +105,8 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, |
| 38 | + |
| 39 | + /* Initialize the identity */ |
| 40 | + memset(identity, 0, sizeof(*identity)); |
| 41 | ++ identity->Version = SEC_WINNT_AUTH_IDENTITY_VERSION; |
| 42 | ++ identity->Length = sizeof(*identity); |
| 43 | + |
| 44 | + useranddomain.tchar_ptr = curlx_convert_UTF8_to_tchar(userp); |
| 45 | + if(!useranddomain.tchar_ptr) |
| 46 | +@@ -195,7 +197,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, |
| 47 | + * |
| 48 | + * identity [in/out] - The identity structure. |
| 49 | + */ |
| 50 | +-void Curl_sspi_free_identity(SEC_WINNT_AUTH_IDENTITY *identity) |
| 51 | ++void Curl_sspi_free_identity(SEC_WINNT_AUTH_IDENTITY_EX *identity) |
| 52 | + { |
| 53 | + if(identity) { |
| 54 | + Curl_safefree(identity->User); |
| 55 | +diff --git a/lib/curl_sspi.h b/lib/curl_sspi.h |
| 56 | +index 3779d51753..ea405f53a7 100644 |
| 57 | +--- a/lib/curl_sspi.h |
| 58 | ++++ b/lib/curl_sspi.h |
| 59 | +@@ -34,14 +34,14 @@ void Curl_sspi_global_cleanup(void); |
| 60 | + |
| 61 | + /* This is used to populate the domain in an SSPI identity structure */ |
| 62 | + CURLcode Curl_override_sspi_http_realm(const char *chlg, |
| 63 | +- SEC_WINNT_AUTH_IDENTITY *identity); |
| 64 | ++ SEC_WINNT_AUTH_IDENTITY_EX *identity); |
| 65 | + |
| 66 | + /* This is used to generate an SSPI identity structure */ |
| 67 | + CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, |
| 68 | +- SEC_WINNT_AUTH_IDENTITY *identity); |
| 69 | ++ SEC_WINNT_AUTH_IDENTITY_EX *identity); |
| 70 | + |
| 71 | + /* This is used to free an SSPI identity structure */ |
| 72 | +-void Curl_sspi_free_identity(SEC_WINNT_AUTH_IDENTITY *identity); |
| 73 | ++void Curl_sspi_free_identity(SEC_WINNT_AUTH_IDENTITY_EX *identity); |
| 74 | + |
| 75 | + /* Forward-declaration of global variables defined in curl_sspi.c */ |
| 76 | + extern PSecurityFunctionTable Curl_pSecFn; |
| 77 | +diff --git a/lib/ldap.c b/lib/ldap.c |
| 78 | +index e223078b03..59369a556d 100644 |
| 79 | +--- a/lib/ldap.c |
| 80 | ++++ b/lib/ldap.c |
| 81 | +@@ -157,7 +157,7 @@ static ULONG ldap_win_bind_auth(LDAP *server, const char *user, |
| 82 | + const char *passwd, unsigned long authflags) |
| 83 | + { |
| 84 | + ULONG method = 0; |
| 85 | +- SEC_WINNT_AUTH_IDENTITY cred; |
| 86 | ++ SEC_WINNT_AUTH_IDENTITY_EX cred; |
| 87 | + ULONG rc = LDAP_AUTH_METHOD_NOT_SUPPORTED; |
| 88 | + |
| 89 | + memset(&cred, 0, sizeof(cred)); |
| 90 | +diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c |
| 91 | +index f29e569cd1..5f4b5e2735 100644 |
| 92 | +--- a/lib/vauth/digest_sspi.c |
| 93 | ++++ b/lib/vauth/digest_sspi.c |
| 94 | +@@ -95,8 +95,8 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, |
| 95 | + CredHandle credentials; |
| 96 | + CtxtHandle context; |
| 97 | + PSecPkgInfo SecurityPackage; |
| 98 | +- SEC_WINNT_AUTH_IDENTITY identity; |
| 99 | +- SEC_WINNT_AUTH_IDENTITY *p_identity; |
| 100 | ++ SEC_WINNT_AUTH_IDENTITY_EX identity; |
| 101 | ++ SEC_WINNT_AUTH_IDENTITY_EX *p_identity; |
| 102 | + SecBuffer chlg_buf; |
| 103 | + SecBuffer resp_buf; |
| 104 | + SecBufferDesc chlg_desc; |
| 105 | +@@ -240,7 +240,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, |
| 106 | + * Returns CURLE_OK on success. |
| 107 | + */ |
| 108 | + CURLcode Curl_override_sspi_http_realm(const char *chlg, |
| 109 | +- SEC_WINNT_AUTH_IDENTITY *identity) |
| 110 | ++ SEC_WINNT_AUTH_IDENTITY_EX *identity) |
| 111 | + { |
| 112 | + xcharp_u domain, dup_domain; |
| 113 | + |
| 114 | +@@ -466,8 +466,8 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, |
| 115 | + |
| 116 | + if(!digest->http_context) { |
| 117 | + CredHandle credentials; |
| 118 | +- SEC_WINNT_AUTH_IDENTITY identity; |
| 119 | +- SEC_WINNT_AUTH_IDENTITY *p_identity; |
| 120 | ++ SEC_WINNT_AUTH_IDENTITY_EX identity; |
| 121 | ++ SEC_WINNT_AUTH_IDENTITY_EX *p_identity; |
| 122 | + SecBuffer resp_buf; |
| 123 | + SecBufferDesc resp_desc; |
| 124 | + unsigned long attrs; |
| 125 | +diff --git a/lib/vauth/vauth.h b/lib/vauth/vauth.h |
| 126 | +index 3e66c89cb5..10a02321e3 100644 |
| 127 | +--- a/lib/vauth/vauth.h |
| 128 | ++++ b/lib/vauth/vauth.h |
| 129 | +@@ -170,8 +170,8 @@ struct ntlmdata { |
| 130 | + #endif |
| 131 | + CredHandle *credentials; |
| 132 | + CtxtHandle *context; |
| 133 | +- SEC_WINNT_AUTH_IDENTITY identity; |
| 134 | +- SEC_WINNT_AUTH_IDENTITY *p_identity; |
| 135 | ++ SEC_WINNT_AUTH_IDENTITY_EX identity; |
| 136 | ++ SEC_WINNT_AUTH_IDENTITY_EX *p_identity; |
| 137 | + size_t token_max; |
| 138 | + BYTE *output_token; |
| 139 | + BYTE *input_token; |
| 140 | +@@ -241,8 +241,8 @@ struct kerberos5data { |
| 141 | + CredHandle *credentials; |
| 142 | + CtxtHandle *context; |
| 143 | + TCHAR *spn; |
| 144 | +- SEC_WINNT_AUTH_IDENTITY identity; |
| 145 | +- SEC_WINNT_AUTH_IDENTITY *p_identity; |
| 146 | ++ SEC_WINNT_AUTH_IDENTITY_EX identity; |
| 147 | ++ SEC_WINNT_AUTH_IDENTITY_EX *p_identity; |
| 148 | + size_t token_max; |
| 149 | + BYTE *output_token; |
| 150 | + #else |
| 151 | +@@ -309,8 +309,8 @@ struct negotiatedata { |
| 152 | + SECURITY_STATUS status; |
| 153 | + CredHandle *credentials; |
| 154 | + CtxtHandle *context; |
| 155 | +- SEC_WINNT_AUTH_IDENTITY identity; |
| 156 | +- SEC_WINNT_AUTH_IDENTITY *p_identity; |
| 157 | ++ SEC_WINNT_AUTH_IDENTITY_EX identity; |
| 158 | ++ SEC_WINNT_AUTH_IDENTITY_EX *p_identity; |
| 159 | + TCHAR *spn; |
| 160 | + size_t token_max; |
| 161 | + BYTE *output_token; |
0 commit comments