mirror of
https://github.com/moparisthebest/curl
synced 2025-03-11 07:39:50 -04:00
sspi: Reworked Curl_sspi_version() to return version components
Reworked the version function to return four version components rather than a string that has to be freed by the caller.
This commit is contained in:
parent
b15434e749
commit
bd38ebc697
@ -974,9 +974,14 @@ void Curl_schannel_cleanup()
|
|||||||
|
|
||||||
size_t Curl_schannel_version(char *buffer, size_t size)
|
size_t Curl_schannel_version(char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
char *version = Curl_sspi_version();
|
int sspi_major = 0, sspi_minor = 0, sspi_build = 0;
|
||||||
size = snprintf(buffer, size, "Schannel/%s", version);
|
|
||||||
free(version);
|
if(!Curl_sspi_version(&sspi_major, &sspi_minor, &sspi_build, NULL))
|
||||||
|
size = snprintf(buffer, size, "WinSSPI/%d.%d.%d", sspi_major, sspi_minor,
|
||||||
|
sspi_build);
|
||||||
|
else
|
||||||
|
size = snprintf(buffer, size, "WinSSPI/unknown");
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -122,50 +122,63 @@ Curl_sspi_global_cleanup(void)
|
|||||||
/*
|
/*
|
||||||
* Curl_sspi_version()
|
* Curl_sspi_version()
|
||||||
*
|
*
|
||||||
* This function returns a string representing the SSPI library version.
|
* This function returns the SSPI library version information.
|
||||||
* It will in any case return a usable string pointer which needs to be freed.
|
|
||||||
*/
|
*/
|
||||||
char *
|
CURLcode Curl_sspi_version(int *major, int *minor, int *build, int *special)
|
||||||
Curl_sspi_version()
|
|
||||||
{
|
{
|
||||||
|
CURLcode result = CURLE_OK;
|
||||||
VS_FIXEDFILEINFO *version_info = NULL;
|
VS_FIXEDFILEINFO *version_info = NULL;
|
||||||
LPTSTR version = NULL;
|
|
||||||
LPTSTR path = NULL;
|
LPTSTR path = NULL;
|
||||||
LPVOID data = NULL;
|
LPVOID data = NULL;
|
||||||
DWORD size, handle;
|
DWORD size, handle;
|
||||||
UINT length;
|
|
||||||
|
|
||||||
if(s_hSecDll) {
|
if(!s_hSecDll)
|
||||||
path = malloc(MAX_PATH);
|
return CURLE_FAILED_INIT;
|
||||||
if(path) {
|
|
||||||
if(GetModuleFileName(s_hSecDll, path, MAX_PATH)) {
|
path = (char *) malloc(MAX_PATH);
|
||||||
size = GetFileVersionInfoSize(path, &handle);
|
if(!path)
|
||||||
if(size) {
|
return CURLE_OUT_OF_MEMORY;
|
||||||
data = malloc(size);
|
|
||||||
if(data) {
|
if(GetModuleFileName(s_hSecDll, path, MAX_PATH)) {
|
||||||
if(GetFileVersionInfo(path, handle, size, data)) {
|
size = GetFileVersionInfoSize(path, &handle);
|
||||||
if(VerQueryValue(data, "\\", (LPVOID*)&version_info, &length)) {
|
if(size) {
|
||||||
version = curl_maprintf("%d.%d.%d.%d",
|
data = malloc(size);
|
||||||
(version_info->dwProductVersionMS>>16)&0xffff,
|
if(data) {
|
||||||
(version_info->dwProductVersionMS>>0)&0xffff,
|
if(GetFileVersionInfo(path, handle, size, data)) {
|
||||||
(version_info->dwProductVersionLS>>16)&0xffff,
|
if(!VerQueryValue(data, "\\", &version_info, &handle))
|
||||||
(version_info->dwProductVersionLS>>0)&0xffff);
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
}
|
|
||||||
}
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
free(path);
|
else
|
||||||
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if(!version)
|
else
|
||||||
version = curl_maprintf("%d", s_pSecFn ? s_pSecFn->dwVersion : 0);
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
/* Set the out parameters */
|
||||||
|
if(!result) {
|
||||||
|
if(major)
|
||||||
|
*major = (version_info->dwProductVersionMS >> 16) & 0xffff;
|
||||||
|
|
||||||
|
if(minor)
|
||||||
|
*minor = (version_info->dwProductVersionMS >> 0) & 0xffff;
|
||||||
|
|
||||||
|
if(build)
|
||||||
|
*build = (version_info->dwProductVersionLS >> 16) & 0xffff;
|
||||||
|
|
||||||
|
if(special)
|
||||||
|
*special = (version_info->dwProductVersionLS >> 0) & 0xffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!version)
|
Curl_safefree(data);
|
||||||
version = strdup("");
|
Curl_safefree(path);
|
||||||
|
|
||||||
return version;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
CURLcode Curl_sspi_global_init(void);
|
CURLcode Curl_sspi_global_init(void);
|
||||||
void Curl_sspi_global_cleanup(void);
|
void Curl_sspi_global_cleanup(void);
|
||||||
char* Curl_sspi_version();
|
CURLcode Curl_sspi_version(int *major, int *minor, int *build, int *special);
|
||||||
char* Curl_sspi_status(SECURITY_STATUS status);
|
char* Curl_sspi_status(SECURITY_STATUS status);
|
||||||
char* Curl_sspi_status_msg(SECURITY_STATUS status);
|
char* Curl_sspi_status_msg(SECURITY_STATUS status);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user