Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fbd30fff
Commit
fbd30fff
authored
May 07, 2021
by
Hans Leidekker
Committed by
Alexandre Julliard
May 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
secur32: Use CRT memory allocators.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
49dbde22
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
255 additions
and
337 deletions
+255
-337
lsa.c
dlls/secur32/lsa.c
+29
-27
negotiate.c
dlls/secur32/negotiate.c
+21
-20
schannel.c
dlls/secur32/schannel.c
+32
-32
secur32.c
dlls/secur32/secur32.c
+51
-97
secur32_priv.h
dlls/secur32/secur32_priv.h
+1
-7
thunks.c
dlls/secur32/thunks.c
+101
-134
wrapper.c
dlls/secur32/wrapper.c
+20
-20
No files found.
dlls/secur32/lsa.c
View file @
fbd30fff
...
...
@@ -21,6 +21,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
...
...
@@ -32,9 +33,9 @@
#include "ntsecpkg.h"
#include "winternl.h"
#include "rpc.h"
#include "secur32_priv.h"
#include "wine/debug.h"
#include "secur32_priv.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
secur32
);
...
...
@@ -91,7 +92,7 @@ NTSTATUS WINAPI LsaCallAuthenticationPackage(HANDLE lsa_handle, ULONG package_id
static
struct
lsa_connection
*
alloc_lsa_connection
(
void
)
{
struct
lsa_connection
*
ret
;
if
(
!
(
ret
=
heap_
alloc
(
sizeof
(
*
ret
))))
return
NULL
;
if
(
!
(
ret
=
m
alloc
(
sizeof
(
*
ret
))))
return
NULL
;
ret
->
magic
=
LSA_MAGIC
;
return
ret
;
}
...
...
@@ -127,7 +128,7 @@ NTSTATUS WINAPI LsaDeregisterLogonProcess(HANDLE LsaHandle)
if
(
!
lsa_conn
||
lsa_conn
->
magic
!=
LSA_MAGIC
)
return
STATUS_INVALID_HANDLE
;
lsa_conn
->
magic
=
0
;
heap_
free
(
lsa_conn
);
free
(
lsa_conn
);
return
STATUS_SUCCESS
;
}
...
...
@@ -145,7 +146,7 @@ NTSTATUS WINAPI LsaEnumerateLogonSessions(PULONG LogonSessionCount,
NTSTATUS
WINAPI
LsaFreeReturnBuffer
(
PVOID
buffer
)
{
TRACE
(
"%p
\n
"
,
buffer
);
heap_
free
(
buffer
);
free
(
buffer
);
return
STATUS_SUCCESS
;
}
...
...
@@ -209,26 +210,26 @@ static NTSTATUS NTAPI lsa_DeleteCredential(LUID *logon_id, ULONG package_id, LSA
static
void
*
NTAPI
lsa_AllocateLsaHeap
(
ULONG
size
)
{
TRACE
(
"%u
\n
"
,
size
);
return
heap_
alloc
(
size
);
return
m
alloc
(
size
);
}
static
void
NTAPI
lsa_FreeLsaHeap
(
void
*
p
)
{
TRACE
(
"%p
\n
"
,
p
);
heap_
free
(
p
);
free
(
p
);
}
static
NTSTATUS
NTAPI
lsa_AllocateClientBuffer
(
PLSA_CLIENT_REQUEST
req
,
ULONG
size
,
void
**
p
)
{
TRACE
(
"%p,%u,%p
\n
"
,
req
,
size
,
p
);
*
p
=
heap_
alloc
(
size
);
*
p
=
m
alloc
(
size
);
return
*
p
?
STATUS_SUCCESS
:
STATUS_NO_MEMORY
;
}
static
NTSTATUS
NTAPI
lsa_FreeClientBuffer
(
PLSA_CLIENT_REQUEST
req
,
void
*
p
)
{
TRACE
(
"%p,%p
\n
"
,
req
,
p
);
heap_
free
(
p
);
free
(
p
);
return
STATUS_SUCCESS
;
}
...
...
@@ -351,13 +352,13 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if
(
principal
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
principal
,
-
1
,
NULL
,
0
);
if
(
!
(
principalW
=
heap_
alloc
(
len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
if
(
!
(
principalW
=
m
alloc
(
len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
MultiByteToWideChar
(
CP_ACP
,
0
,
principal
,
-
1
,
principalW
,
len
);
}
if
(
package
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
package
,
-
1
,
NULL
,
0
);
if
(
!
(
packageW
=
heap_
alloc
(
len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
if
(
!
(
packageW
=
m
alloc
(
len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
MultiByteToWideChar
(
CP_ACP
,
0
,
package
,
-
1
,
packageW
,
len
);
}
if
(
auth_data
)
...
...
@@ -366,23 +367,23 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if
(
id
->
Flags
==
SEC_WINNT_AUTH_IDENTITY_ANSI
)
{
if
(
!
(
auth_dataW
=
heap_
alloc
(
sizeof
(
SEC_WINNT_AUTH_IDENTITY_W
)
)))
goto
done
;
if
(
!
(
auth_dataW
=
m
alloc
(
sizeof
(
SEC_WINNT_AUTH_IDENTITY_W
)
)))
goto
done
;
if
(
id
->
UserLength
)
{
len_user
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
char
*
)
id
->
User
,
id
->
UserLength
,
NULL
,
0
);
if
(
!
(
user
=
heap_
alloc
(
len_user
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
if
(
!
(
user
=
m
alloc
(
len_user
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
MultiByteToWideChar
(
CP_ACP
,
0
,
(
char
*
)
id
->
User
,
id
->
UserLength
,
user
,
len_user
);
}
if
(
id
->
DomainLength
)
{
len_domain
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
char
*
)
id
->
Domain
,
id
->
DomainLength
,
NULL
,
0
);
if
(
!
(
domain
=
heap_
alloc
(
len_domain
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
if
(
!
(
domain
=
m
alloc
(
len_domain
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
MultiByteToWideChar
(
CP_ACP
,
0
,
(
char
*
)
id
->
Domain
,
id
->
DomainLength
,
domain
,
len_domain
);
}
if
(
id
->
PasswordLength
)
{
len_passwd
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
char
*
)
id
->
Password
,
id
->
PasswordLength
,
NULL
,
0
);
if
(
!
(
passwd
=
heap_
alloc
(
len_passwd
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
if
(
!
(
passwd
=
m
alloc
(
len_passwd
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
MultiByteToWideChar
(
CP_ACP
,
0
,
(
char
*
)
id
->
Password
,
id
->
PasswordLength
,
passwd
,
len_passwd
);
}
auth_dataW
->
Flags
=
SEC_WINNT_AUTH_IDENTITY_UNICODE
;
...
...
@@ -399,12 +400,12 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
status
=
lsa_AcquireCredentialsHandleW
(
principalW
,
packageW
,
credentials_use
,
logon_id
,
auth_dataW
,
get_key_fn
,
get_key_arg
,
credential
,
ts_expiry
);
done:
if
(
auth_dataW
!=
(
SEC_WINNT_AUTH_IDENTITY_W
*
)
id
)
heap_
free
(
auth_dataW
);
heap_
free
(
packageW
);
heap_
free
(
principalW
);
heap_
free
(
user
);
heap_
free
(
domain
);
heap_
free
(
passwd
);
if
(
auth_dataW
!=
(
SEC_WINNT_AUTH_IDENTITY_W
*
)
id
)
free
(
auth_dataW
);
free
(
packageW
);
free
(
principalW
);
free
(
user
);
free
(
domain
);
free
(
passwd
);
return
status
;
}
...
...
@@ -487,13 +488,13 @@ static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA(
if
(
target_name
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
target_name
,
-
1
,
NULL
,
0
);
if
(
!
(
targetW
=
heap_
alloc
(
len
*
sizeof
(
SEC_WCHAR
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
targetW
=
m
alloc
(
len
*
sizeof
(
SEC_WCHAR
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
target_name
,
-
1
,
targetW
,
len
);
}
status
=
lsa_InitializeSecurityContextW
(
credential
,
context
,
targetW
,
context_req
,
reserved1
,
target_data_rep
,
input
,
reserved2
,
new_context
,
output
,
context_attr
,
ts_expiry
);
heap_
free
(
targetW
);
free
(
targetW
);
return
status
;
}
...
...
@@ -583,7 +584,8 @@ static SecPkgInfoA *package_infoWtoA( const SecPkgInfoW *info )
int
size_name
=
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Name
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
int
size_comment
=
WideCharToMultiByte
(
CP_ACP
,
0
,
info
->
Comment
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
(
ret
=
heap_alloc
(
sizeof
(
*
ret
)
+
size_name
+
size_comment
)))
return
NULL
;
/* freed with FreeContextBuffer */
if
(
!
(
ret
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
*
ret
)
+
size_name
+
size_comment
)))
return
NULL
;
ret
->
fCapabilities
=
info
->
fCapabilities
;
ret
->
wVersion
=
info
->
wVersion
;
ret
->
wRPCID
=
info
->
wRPCID
;
...
...
@@ -801,9 +803,9 @@ static void add_package(struct lsa_package *package)
struct
lsa_package
*
new_loaded_packages
;
if
(
!
loaded_packages
)
new_loaded_packages
=
heap_
alloc
(
sizeof
(
*
new_loaded_packages
));
new_loaded_packages
=
m
alloc
(
sizeof
(
*
new_loaded_packages
));
else
new_loaded_packages
=
heap_
realloc
(
loaded_packages
,
sizeof
(
*
new_loaded_packages
)
*
(
loaded_packages_count
+
1
));
new_loaded_packages
=
realloc
(
loaded_packages
,
sizeof
(
*
new_loaded_packages
)
*
(
loaded_packages_count
+
1
));
if
(
new_loaded_packages
)
{
...
...
@@ -904,7 +906,7 @@ void load_auth_packages(void)
{
SecPkgInfoW
*
info
;
info
=
heap_
alloc
(
loaded_packages
[
i
].
lsa_table_count
*
sizeof
(
*
info
));
info
=
m
alloc
(
loaded_packages
[
i
].
lsa_table_count
*
sizeof
(
*
info
));
if
(
info
)
{
NTSTATUS
status
;
...
...
@@ -913,7 +915,7 @@ void load_auth_packages(void)
if
(
status
==
STATUS_SUCCESS
)
SECUR32_addPackages
(
provider
,
loaded_packages
[
i
].
lsa_table_count
,
NULL
,
info
);
heap_
free
(
info
);
free
(
info
);
}
}
}
...
...
dlls/secur32/negotiate.c
View file @
fbd30fff
...
...
@@ -18,6 +18,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "sspi.h"
...
...
@@ -78,7 +79,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
pLogonID
,
pAuthData
,
pGetKeyFn
,
pGetKeyArgument
,
phCredential
,
ptsExpiry
);
if
(
!
pszPackage
)
return
SEC_E_SECPKG_NOT_FOUND
;
if
(
!
(
cred
=
heap_alloc_zero
(
sizeof
(
*
cred
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
cred
=
calloc
(
1
,
sizeof
(
*
cred
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
((
package
=
SECUR32_findPackageW
(
kerberosW
)))
{
...
...
@@ -103,7 +104,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
return
SEC_E_OK
;
}
heap_
free
(
cred
);
free
(
cred
);
return
ret
;
}
...
...
@@ -126,7 +127,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if
(
pszPackage
)
{
int
package_len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
pszPackage
,
-
1
,
NULL
,
0
);
if
(
!
(
package
=
heap_
alloc
(
package_len
*
sizeof
(
SEC_WCHAR
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
package
=
m
alloc
(
package_len
*
sizeof
(
SEC_WCHAR
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
pszPackage
,
-
1
,
package
,
package_len
);
}
if
(
pAuthData
)
...
...
@@ -136,14 +137,14 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if
(
identity
->
Flags
==
SEC_WINNT_AUTH_IDENTITY_ANSI
)
{
if
(
!
(
identityW
=
heap_
alloc
(
sizeof
(
*
identityW
)
)))
goto
done
;
if
(
!
(
identityW
=
m
alloc
(
sizeof
(
*
identityW
)
)))
goto
done
;
if
(
!
identity
->
UserLength
)
user_len
=
0
;
else
{
user_len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPCSTR
)
identity
->
User
,
identity
->
UserLength
,
NULL
,
0
);
if
(
!
(
user
=
heap_
alloc
(
user_len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
if
(
!
(
user
=
m
alloc
(
user_len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPCSTR
)
identity
->
User
,
identity
->
UserLength
,
user
,
user_len
);
}
...
...
@@ -152,7 +153,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{
domain_len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPCSTR
)
identity
->
Domain
,
identity
->
DomainLength
,
NULL
,
0
);
if
(
!
(
domain
=
heap_
alloc
(
domain_len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
if
(
!
(
domain
=
m
alloc
(
domain_len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPCSTR
)
identity
->
Domain
,
identity
->
DomainLength
,
domain
,
domain_len
);
}
...
...
@@ -161,7 +162,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{
passwd_len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPCSTR
)
identity
->
Password
,
identity
->
PasswordLength
,
NULL
,
0
);
if
(
!
(
passwd
=
heap_
alloc
(
passwd_len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
if
(
!
(
passwd
=
m
alloc
(
passwd_len
*
sizeof
(
SEC_WCHAR
)
)))
goto
done
;
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPCSTR
)
identity
->
Password
,
identity
->
PasswordLength
,
passwd
,
passwd_len
);
}
...
...
@@ -178,11 +179,11 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
ret
=
nego_AcquireCredentialsHandleW
(
NULL
,
package
,
fCredentialUse
,
pLogonID
,
identityW
,
pGetKeyFn
,
pGetKeyArgument
,
phCredential
,
ptsExpiry
);
done:
heap_
free
(
package
);
heap_
free
(
user
);
heap_
free
(
domain
);
heap_
free
(
passwd
);
heap_
free
(
identityW
);
free
(
package
);
free
(
user
);
free
(
domain
);
free
(
passwd
);
free
(
identityW
);
return
ret
;
}
...
...
@@ -210,7 +211,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
else
if
(
phCredential
)
{
handle
=
cred
=
(
struct
sec_handle
*
)
phCredential
->
dwLower
;
if
(
!
(
new_ctxt
=
ctxt
=
heap_alloc_zero
(
sizeof
(
*
ctxt
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
new_ctxt
=
ctxt
=
calloc
(
1
,
sizeof
(
*
ctxt
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
ctxt
->
krb
=
cred
->
krb
;
ctxt
->
ntlm
=
cred
->
ntlm
;
}
...
...
@@ -244,7 +245,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
}
}
heap_
free
(
new_ctxt
);
free
(
new_ctxt
);
return
ret
;
}
...
...
@@ -268,13 +269,13 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextA(
if
(
pszTargetName
)
{
int
target_len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
pszTargetName
,
-
1
,
NULL
,
0
);
if
(
!
(
target
=
heap_
alloc
(
target_len
*
sizeof
(
SEC_WCHAR
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
target
=
m
alloc
(
target_len
*
sizeof
(
SEC_WCHAR
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
pszTargetName
,
-
1
,
target
,
target_len
);
}
ret
=
nego_InitializeSecurityContextW
(
phCredential
,
phContext
,
target
,
fContextReq
,
Reserved1
,
TargetDataRep
,
pInput
,
Reserved2
,
phNewContext
,
pOutput
,
pfContextAttr
,
ptsExpiry
);
heap_
free
(
target
);
free
(
target
);
return
ret
;
}
...
...
@@ -300,7 +301,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
else
if
(
phCredential
)
{
handle
=
cred
=
(
struct
sec_handle
*
)
phCredential
->
dwLower
;
if
(
!
(
new_ctxt
=
ctxt
=
heap_alloc_zero
(
sizeof
(
*
ctxt
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
new_ctxt
=
ctxt
=
calloc
(
1
,
sizeof
(
*
ctxt
)
)))
return
SEC_E_INSUFFICIENT_MEMORY
;
ctxt
->
krb
=
cred
->
krb
;
ctxt
->
ntlm
=
cred
->
ntlm
;
}
...
...
@@ -334,7 +335,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
}
}
heap_
free
(
new_ctxt
);
free
(
new_ctxt
);
return
ret
;
}
...
...
@@ -374,7 +375,7 @@ static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContex
ret
=
ctxt
->
ntlm
->
fnTableW
.
DeleteSecurityContext
(
&
ctxt
->
handle_ntlm
);
}
TRACE
(
"freeing %p
\n
"
,
ctxt
);
heap_
free
(
ctxt
);
free
(
ctxt
);
return
ret
;
}
...
...
@@ -533,7 +534,7 @@ static SECURITY_STATUS SEC_ENTRY nego_FreeCredentialsHandle(PCredHandle phCreden
if
(
cred
->
krb
)
cred
->
krb
->
fnTableW
.
FreeCredentialsHandle
(
&
cred
->
handle_krb
);
if
(
cred
->
ntlm
)
cred
->
ntlm
->
fnTableW
.
FreeCredentialsHandle
(
&
cred
->
handle_ntlm
);
heap_
free
(
cred
);
free
(
cred
);
return
SEC_E_OK
;
}
...
...
dlls/secur32/schannel.c
View file @
fbd30fff
...
...
@@ -20,6 +20,7 @@
#include <assert.h>
#include <stdarg.h>
#include <stdlib.h>
#include <errno.h>
#define NONAMELESSUNION
...
...
@@ -98,7 +99,7 @@ static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type)
{
/* Grow the table */
SIZE_T
new_size
=
schan_handle_table_size
+
(
schan_handle_table_size
>>
1
);
struct
schan_handle
*
new_table
=
heap_
realloc
(
schan_handle_table
,
new_size
*
sizeof
(
*
schan_handle_table
));
struct
schan_handle
*
new_table
=
realloc
(
schan_handle_table
,
new_size
*
sizeof
(
*
schan_handle_table
));
if
(
!
new_table
)
{
ERR
(
"Failed to grow the handle table
\n
"
);
...
...
@@ -521,7 +522,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
return
SEC_E_NO_AUTHENTICATING_AUTHORITY
;
}
if
(
!
(
creds
=
heap_
alloc
(
sizeof
(
*
creds
))))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
creds
=
m
alloc
(
sizeof
(
*
creds
))))
return
SEC_E_INSUFFICIENT_MEMORY
;
creds
->
credential_use
=
SECPKG_CRED_OUTBOUND
;
creds
->
enabled_protocols
=
enabled_protocols
;
...
...
@@ -545,7 +546,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
return
status
;
fail:
heap_
free
(
creds
);
free
(
creds
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
key_blob
.
pbData
);
return
SEC_E_INTERNAL_ERROR
;
}
...
...
@@ -566,14 +567,13 @@ static SECURITY_STATUS schan_AcquireServerCredentials(const SCHANNEL_CRED *schan
ULONG_PTR
handle
;
struct
schan_credentials
*
creds
;
creds
=
heap_alloc_zero
(
sizeof
(
*
creds
));
if
(
!
creds
)
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
creds
=
calloc
(
1
,
sizeof
(
*
creds
))))
return
SEC_E_INSUFFICIENT_MEMORY
;
creds
->
credential_use
=
SECPKG_CRED_INBOUND
;
handle
=
schan_alloc_handle
(
creds
,
SCHAN_HANDLE_CRED
);
if
(
handle
==
SCHAN_INVALID_HANDLE
)
{
heap_
free
(
creds
);
free
(
creds
);
return
SEC_E_INTERNAL_ERROR
;
}
...
...
@@ -636,7 +636,7 @@ static SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle(
if
(
!
creds
)
return
SEC_E_INVALID_HANDLE
;
if
(
creds
->
credential_use
==
SECPKG_CRED_OUTBOUND
)
schan_funcs
->
free_certificate_credentials
(
creds
);
heap_
free
(
creds
);
free
(
creds
);
return
SEC_E_OK
;
}
...
...
@@ -675,10 +675,10 @@ static void schan_resize_current_buffer(const struct schan_buffers *s, SIZE_T mi
while
(
new_size
<
min_size
)
new_size
*=
2
;
if
(
b
->
pvBuffer
)
new_data
=
heap_realloc
(
b
->
pvBuffer
,
new_size
);
if
(
b
->
pvBuffer
)
/* freed with FreeContextBuffer */
new_data
=
RtlReAllocateHeap
(
GetProcessHeap
(),
0
,
b
->
pvBuffer
,
new_size
);
else
new_data
=
heap_alloc
(
new_size
);
new_data
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
new_size
);
if
(
!
new_data
)
{
...
...
@@ -925,21 +925,20 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
return
SEC_E_INVALID_HANDLE
;
}
ctx
=
heap_alloc
(
sizeof
(
*
ctx
));
if
(
!
ctx
)
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
ctx
=
malloc
(
sizeof
(
*
ctx
))))
return
SEC_E_INSUFFICIENT_MEMORY
;
ctx
->
cert
=
NULL
;
handle
=
schan_alloc_handle
(
ctx
,
SCHAN_HANDLE_CTX
);
if
(
handle
==
SCHAN_INVALID_HANDLE
)
{
heap_
free
(
ctx
);
free
(
ctx
);
return
SEC_E_INTERNAL_ERROR
;
}
if
(
!
schan_funcs
->
create_session
(
&
ctx
->
session
,
cred
))
{
schan_free_handle
(
handle
,
SCHAN_HANDLE_CTX
);
heap_
free
(
ctx
);
free
(
ctx
);
return
SEC_E_INTERNAL_ERROR
;
}
...
...
@@ -954,13 +953,13 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
if
(
pszTargetName
&&
*
pszTargetName
)
{
UINT
len
=
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
pszTargetName
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
char
*
target
=
heap_
alloc
(
len
);
char
*
target
=
m
alloc
(
len
);
if
(
target
)
{
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
pszTargetName
,
-
1
,
target
,
len
,
NULL
,
NULL
);
schan_funcs
->
set_session_target
(
ctx
->
session
,
target
);
heap_
free
(
target
);
free
(
target
);
}
}
...
...
@@ -1077,7 +1076,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
if
(
pszTargetName
)
{
INT
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
pszTargetName
,
-
1
,
NULL
,
0
);
if
(
!
(
target_name
=
heap_
alloc
(
len
*
sizeof
(
*
target_name
))))
return
SEC_E_INSUFFICIENT_MEMORY
;
if
(
!
(
target_name
=
m
alloc
(
len
*
sizeof
(
*
target_name
))))
return
SEC_E_INSUFFICIENT_MEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
pszTargetName
,
-
1
,
target_name
,
len
);
}
...
...
@@ -1085,7 +1084,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
fContextReq
,
Reserved1
,
TargetDataRep
,
pInput
,
Reserved2
,
phNewContext
,
pOutput
,
pfContextAttr
,
ptsExpiry
);
heap_
free
(
target_name
);
free
(
target_name
);
return
ret
;
}
...
...
@@ -1244,7 +1243,8 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
return
GetLastError
();
bindings
->
BindingsLength
=
sizeof
(
*
bindings
->
Bindings
)
+
sizeof
(
prefix
)
-
1
+
hash_size
;
bindings
->
Bindings
=
heap_alloc_zero
(
bindings
->
BindingsLength
);
/* freed with FreeContextBuffer */
bindings
->
Bindings
=
RtlAllocateHeap
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
bindings
->
BindingsLength
);
if
(
!
bindings
->
Bindings
)
return
SEC_E_INSUFFICIENT_MEMORY
;
...
...
@@ -1386,7 +1386,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
buffer
=
&
message
->
pBuffers
[
idx
];
data_size
=
buffer
->
cbBuffer
;
data
=
heap_
alloc
(
data_size
);
data
=
m
alloc
(
data_size
);
memcpy
(
data
,
buffer
->
pvBuffer
,
data_size
);
if
(
schan_find_sec_buffer_idx
(
message
,
0
,
SECBUFFER_STREAM_HEADER
)
!=
-
1
)
...
...
@@ -1404,7 +1404,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
b
=
&
ctx
->
transport
.
out
;
b
->
desc
->
pBuffers
[
b
->
current_buffer_idx
].
cbBuffer
=
b
->
offset
;
heap_
free
(
data
);
free
(
data
);
TRACE
(
"Returning %#x.
\n
"
,
status
);
...
...
@@ -1520,7 +1520,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
}
data_size
=
expected_size
-
ctx
->
header_size
;
data
=
heap_
alloc
(
data_size
);
data
=
m
alloc
(
data_size
);
init_schan_buffers
(
&
ctx
->
transport
.
in
,
message
,
schan_decrypt_message_get_next_buffer
);
ctx
->
transport
.
in
.
limit
=
expected_size
;
...
...
@@ -1541,7 +1541,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
if
(
status
!=
SEC_E_OK
)
{
heap_
free
(
data
);
free
(
data
);
ERR
(
"Returning %x
\n
"
,
status
);
return
status
;
}
...
...
@@ -1555,7 +1555,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
TRACE
(
"Received %ld bytes
\n
"
,
received
);
memcpy
(
buf_ptr
+
ctx
->
header_size
,
data
,
received
);
heap_
free
(
data
);
free
(
data
);
schan_decrypt_fill_buffer
(
message
,
SECBUFFER_DATA
,
buf_ptr
+
ctx
->
header_size
,
received
);
...
...
@@ -1586,7 +1586,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DeleteSecurityContext(PCtxtHandle context
if
(
ctx
->
cert
)
CertFreeCertificateContext
(
ctx
->
cert
);
schan_funcs
->
dispose_session
(
ctx
->
session
);
heap_
free
(
ctx
);
free
(
ctx
);
return
SEC_E_OK
;
}
...
...
@@ -1597,7 +1597,7 @@ static const SecurityFunctionTableA schanTableA = {
schan_AcquireCredentialsHandleA
,
schan_FreeCredentialsHandle
,
NULL
,
/* Reserved2 */
schan_InitializeSecurityContextA
,
schan_InitializeSecurityContextA
,
NULL
,
/* AcceptSecurityContext */
NULL
,
/* CompleteAuthToken */
schan_DeleteSecurityContext
,
...
...
@@ -1628,7 +1628,7 @@ static const SecurityFunctionTableW schanTableW = {
schan_AcquireCredentialsHandleW
,
schan_FreeCredentialsHandle
,
NULL
,
/* Reserved2 */
schan_InitializeSecurityContextW
,
schan_InitializeSecurityContextW
,
NULL
,
/* AcceptSecurityContext */
NULL
,
/* CompleteAuthToken */
schan_DeleteSecurityContext
,
...
...
@@ -1691,7 +1691,7 @@ void SECUR32_initSchannelSP(void)
return
;
}
schan_handle_table
=
heap_
alloc
(
64
*
sizeof
(
*
schan_handle_table
));
schan_handle_table
=
m
alloc
(
64
*
sizeof
(
*
schan_handle_table
));
if
(
!
schan_handle_table
)
{
ERR
(
"Failed to allocate schannel handle table.
\n
"
);
...
...
@@ -1710,7 +1710,7 @@ void SECUR32_initSchannelSP(void)
return
;
fail:
heap_
free
(
schan_handle_table
);
free
(
schan_handle_table
);
schan_handle_table
=
NULL
;
return
;
}
...
...
@@ -1729,7 +1729,7 @@ void SECUR32_deinitSchannelSP(void)
{
struct
schan_context
*
ctx
=
schan_free_handle
(
i
,
SCHAN_HANDLE_CTX
);
schan_funcs
->
dispose_session
(
ctx
->
session
);
heap_
free
(
ctx
);
free
(
ctx
);
}
}
i
=
schan_handle_count
;
...
...
@@ -1740,10 +1740,10 @@ void SECUR32_deinitSchannelSP(void)
struct
schan_credentials
*
cred
;
cred
=
schan_free_handle
(
i
,
SCHAN_HANDLE_CRED
);
schan_funcs
->
free_certificate_credentials
(
cred
);
heap_
free
(
cred
);
free
(
cred
);
}
}
heap_
free
(
schan_handle_table
);
free
(
schan_handle_table
);
__wine_init_unix_lib
(
hsecur32
,
DLL_PROCESS_DETACH
,
NULL
,
NULL
);
schan_funcs
=
NULL
;
...
...
dlls/secur32/secur32.c
View file @
fbd30fff
...
...
@@ -174,56 +174,10 @@ PSecurityFunctionTableW WINAPI InitSecurityInterfaceW(void)
return
&
securityFunctionTableW
;
}
static
WCHAR
*
SECUR32_strdupW
(
const
WCHAR
*
str
)
static
WCHAR
*
strdupW
(
const
WCHAR
*
str
)
{
WCHAR
*
ret
=
NULL
;
if
(
str
&&
(
ret
=
heap_alloc
((
wcslen
(
str
)
+
1
)
*
sizeof
(
WCHAR
))))
wcscpy
(
ret
,
str
);
return
ret
;
}
PWSTR
SECUR32_AllocWideFromMultiByte
(
PCSTR
str
)
{
PWSTR
ret
;
if
(
str
)
{
int
charsNeeded
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
if
(
charsNeeded
)
{
ret
=
heap_alloc
(
charsNeeded
*
sizeof
(
WCHAR
));
if
(
ret
)
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
charsNeeded
);
}
else
ret
=
NULL
;
}
else
ret
=
NULL
;
return
ret
;
}
PSTR
SECUR32_AllocMultiByteFromWide
(
PCWSTR
str
)
{
PSTR
ret
;
if
(
str
)
{
int
charsNeeded
=
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
charsNeeded
)
{
ret
=
heap_alloc
(
charsNeeded
);
if
(
ret
)
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
charsNeeded
,
NULL
,
NULL
);
}
else
ret
=
NULL
;
}
else
ret
=
NULL
;
if
(
str
&&
(
ret
=
malloc
(
(
wcslen
(
str
)
+
1
)
*
sizeof
(
WCHAR
)
)))
wcscpy
(
ret
,
str
);
return
ret
;
}
...
...
@@ -369,6 +323,17 @@ static void _makeFnTableW(PSecurityFunctionTableW fnTableW,
}
}
static
WCHAR
*
strdupAW
(
const
char
*
str
)
{
WCHAR
*
ret
=
NULL
;
if
(
str
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
if
((
ret
=
malloc
(
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
);
}
return
ret
;
}
static
void
_copyPackageInfo
(
PSecPkgInfoW
info
,
const
SecPkgInfoA
*
inInfoA
,
const
SecPkgInfoW
*
inInfoW
)
{
...
...
@@ -380,13 +345,13 @@ static void _copyPackageInfo(PSecPkgInfoW info, const SecPkgInfoA *inInfoA,
memcpy
(
info
,
inInfoW
?
inInfoW
:
(
const
SecPkgInfoW
*
)
inInfoA
,
sizeof
(
*
info
));
if
(
inInfoW
)
{
info
->
Name
=
SECUR32_
strdupW
(
inInfoW
->
Name
);
info
->
Comment
=
SECUR32_
strdupW
(
inInfoW
->
Comment
);
info
->
Name
=
strdupW
(
inInfoW
->
Name
);
info
->
Comment
=
strdupW
(
inInfoW
->
Comment
);
}
else
{
info
->
Name
=
SECUR32_AllocWideFromMultiByte
(
inInfoA
->
Name
);
info
->
Comment
=
SECUR32_AllocWideFromMultiByte
(
inInfoA
->
Comment
);
info
->
Name
=
strdupAW
(
inInfoA
->
Name
);
info
->
Comment
=
strdupAW
(
inInfoA
->
Comment
);
}
}
}
...
...
@@ -400,8 +365,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
if
(
!
providerTable
)
{
providerTable
=
heap_alloc
(
sizeof
(
SecureProviderTable
));
if
(
!
providerTable
)
if
(
!
(
providerTable
=
malloc
(
sizeof
(
*
ret
))))
{
LeaveCriticalSection
(
&
cs
);
return
NULL
;
...
...
@@ -410,8 +374,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
list_init
(
&
providerTable
->
table
);
}
ret
=
heap_alloc
(
sizeof
(
SecureProvider
));
if
(
!
ret
)
if
(
!
(
ret
=
malloc
(
sizeof
(
*
ret
))))
{
LeaveCriticalSection
(
&
cs
);
return
NULL
;
...
...
@@ -422,17 +385,17 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
if
(
fnTableA
||
fnTableW
)
{
ret
->
moduleName
=
moduleName
?
SECUR32_
strdupW
(
moduleName
)
:
NULL
;
ret
->
moduleName
=
moduleName
?
strdupW
(
moduleName
)
:
NULL
;
_makeFnTableA
(
&
ret
->
fnTableA
,
fnTableA
,
fnTableW
);
_makeFnTableW
(
&
ret
->
fnTableW
,
fnTableA
,
fnTableW
);
ret
->
loaded
=
!
moduleName
;
}
else
{
ret
->
moduleName
=
SECUR32_
strdupW
(
moduleName
);
ret
->
moduleName
=
strdupW
(
moduleName
);
ret
->
loaded
=
FALSE
;
}
LeaveCriticalSection
(
&
cs
);
return
ret
;
}
...
...
@@ -449,8 +412,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
if
(
!
packageTable
)
{
packageTable
=
heap_alloc
(
sizeof
(
SecurePackageTable
));
if
(
!
packageTable
)
if
(
!
(
packageTable
=
malloc
(
sizeof
(
*
packageTable
))))
{
LeaveCriticalSection
(
&
cs
);
return
;
...
...
@@ -459,19 +421,17 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
packageTable
->
numPackages
=
0
;
list_init
(
&
packageTable
->
table
);
}
for
(
i
=
0
;
i
<
toAdd
;
i
++
)
{
SecurePackage
*
package
=
heap_alloc
(
sizeof
(
SecurePackage
))
;
if
(
!
package
)
continue
;
SecurePackage
*
package
;
if
(
!
(
package
=
malloc
(
sizeof
(
*
package
))))
continue
;
list_add_tail
(
&
packageTable
->
table
,
&
package
->
entry
);
package
->
provider
=
provider
;
_copyPackageInfo
(
&
package
->
infoW
,
infoA
?
&
infoA
[
i
]
:
NULL
,
infoW
?
&
infoW
[
i
]
:
NULL
);
_copyPackageInfo
(
&
package
->
infoW
,
infoA
?
&
infoA
[
i
]
:
NULL
,
infoW
?
&
infoW
[
i
]
:
NULL
);
}
packageTable
->
numPackages
+=
toAdd
;
...
...
@@ -599,14 +559,11 @@ SecurePackage *SECUR32_findPackageW(PCWSTR packageName)
LIST_FOR_EACH_ENTRY
(
ret
,
&
packageTable
->
table
,
SecurePackage
,
entry
)
{
matched
=
!
lstrcmpiW
(
ret
->
infoW
.
Name
,
packageName
);
if
(
matched
)
break
;
if
(
matched
)
break
;
}
if
(
!
matched
)
return
NULL
;
if
(
!
matched
)
return
NULL
;
if
(
ret
->
provider
&&
!
ret
->
provider
->
loaded
)
if
(
ret
->
provider
&&
!
ret
->
provider
->
loaded
)
{
ret
->
provider
->
lib
=
LoadLibraryW
(
ret
->
provider
->
moduleName
);
if
(
ret
->
provider
->
lib
)
...
...
@@ -668,28 +625,26 @@ static void SECUR32_freeProviders(void)
LIST_FOR_EACH_ENTRY_SAFE
(
package
,
package_next
,
&
packageTable
->
table
,
SecurePackage
,
entry
)
{
heap_
free
(
package
->
infoW
.
Name
);
heap_
free
(
package
->
infoW
.
Comment
);
heap_
free
(
package
);
free
(
package
->
infoW
.
Name
);
free
(
package
->
infoW
.
Comment
);
free
(
package
);
}
heap_
free
(
packageTable
);
free
(
packageTable
);
packageTable
=
NULL
;
}
if
(
providerTable
)
{
SecureProvider
*
provider
,
*
provider_next
;
LIST_FOR_EACH_ENTRY_SAFE
(
provider
,
provider_next
,
&
providerTable
->
table
,
SecureProvider
,
entry
)
LIST_FOR_EACH_ENTRY_SAFE
(
provider
,
provider_next
,
&
providerTable
->
table
,
SecureProvider
,
entry
)
{
heap_free
(
provider
->
moduleName
);
if
(
provider
->
lib
)
FreeLibrary
(
provider
->
lib
);
heap_free
(
provider
);
free
(
provider
->
moduleName
);
if
(
provider
->
lib
)
FreeLibrary
(
provider
->
lib
);
free
(
provider
);
}
heap_
free
(
providerTable
);
free
(
providerTable
);
providerTable
=
NULL
;
}
...
...
@@ -704,9 +659,9 @@ static void SECUR32_freeProviders(void)
* The sample ssp seems to use LocalAlloc/LocalFee, but there doesn't seem to
* be any guarantee, nor is there an alloc function in secur32.
*/
SECURITY_STATUS
WINAPI
FreeContextBuffer
(
PVOID
pv
)
SECURITY_STATUS
WINAPI
FreeContextBuffer
(
void
*
pv
)
{
heap_free
(
pv
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
pv
);
return
SEC_E_OK
;
}
...
...
@@ -738,8 +693,8 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesW(PULONG pcPackages,
}
if
(
bytesNeeded
)
{
*
ppPackageInfo
=
heap_alloc
(
bytesNeeded
);
if
(
*
ppPackageInfo
)
/* freed with FeeContextBuffer */
if
(
(
*
ppPackageInfo
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
bytesNeeded
))
)
{
ULONG
i
=
0
;
PWSTR
nextString
;
...
...
@@ -803,8 +758,8 @@ static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages,
bytesNeeded
+=
WideCharToMultiByte
(
CP_ACP
,
0
,
info
[
i
].
Comment
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
}
ret
=
heap_alloc
(
bytesNeeded
);
if
(
ret
)
/* freed with FreeContextBuffer */
if
(
(
ret
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
bytesNeeded
))
)
{
PSTR
nextString
;
...
...
@@ -895,7 +850,7 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesA(PULONG pcPackages,
* nSize returns the number of characters written when lpNameBuffer is not
* NULL or the size of the buffer needed to hold the name when the buffer
* is too short or lpNameBuffer is NULL.
*
*
* It the buffer is too short, ERROR_INSUFFICIENT_BUFFER error will be set.
*/
BOOLEAN
WINAPI
GetComputerObjectNameA
(
...
...
@@ -908,8 +863,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
TRACE
(
"(%d %p %p)
\n
"
,
NameFormat
,
lpNameBuffer
,
nSize
);
if
(
lpNameBuffer
)
{
bufferW
=
heap_alloc
(
sizeW
*
sizeof
(
WCHAR
));
if
(
bufferW
==
NULL
)
{
if
(
!
(
bufferW
=
malloc
(
sizeW
*
sizeof
(
WCHAR
))))
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
}
...
...
@@ -922,7 +876,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
}
else
*
nSize
=
sizeW
;
heap_
free
(
bufferW
);
free
(
bufferW
);
return
rc
;
}
...
...
@@ -1115,7 +1069,7 @@ BOOLEAN WINAPI GetUserNameExA(
ULONG
sizeW
=
*
nSize
;
TRACE
(
"(%d %p %p)
\n
"
,
NameFormat
,
lpNameBuffer
,
nSize
);
if
(
lpNameBuffer
)
{
bufferW
=
heap_
alloc
(
sizeW
*
sizeof
(
WCHAR
));
bufferW
=
m
alloc
(
sizeW
*
sizeof
(
WCHAR
));
if
(
bufferW
==
NULL
)
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
...
...
@@ -1138,7 +1092,7 @@ BOOLEAN WINAPI GetUserNameExA(
}
else
*
nSize
=
sizeW
;
heap_
free
(
bufferW
);
free
(
bufferW
);
return
rc
;
}
...
...
dlls/secur32/secur32_priv.h
View file @
fbd30fff
...
...
@@ -23,9 +23,8 @@
#include <sys/types.h>
#include <limits.h>
#include "wine/heap.h"
#include "wine/list.h"
#include "schannel.h"
#include "wine/list.h"
extern
HINSTANCE
hsecur32
DECLSPEC_HIDDEN
;
...
...
@@ -71,11 +70,6 @@ SecurePackage *SECUR32_findPackageW(PCWSTR packageName) DECLSPEC_HIDDEN;
*/
SecurePackage
*
SECUR32_findPackageA
(
PCSTR
packageName
)
DECLSPEC_HIDDEN
;
/* A few string helpers; will return NULL if str is NULL. Free return with
* HeapFree */
PWSTR
SECUR32_AllocWideFromMultiByte
(
PCSTR
str
)
DECLSPEC_HIDDEN
;
PSTR
SECUR32_AllocMultiByteFromWide
(
PCWSTR
str
)
DECLSPEC_HIDDEN
;
/* Initialization functions for built-in providers */
void
SECUR32_initSchannelSP
(
void
)
DECLSPEC_HIDDEN
;
void
SECUR32_initNegotiateSP
(
void
)
DECLSPEC_HIDDEN
;
...
...
dlls/secur32/thunks.c
View file @
fbd30fff
...
...
@@ -58,6 +58,18 @@ SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleA(
return
ret
;
}
static
char
*
strdupWA
(
const
WCHAR
*
str
)
{
char
*
ret
=
NULL
;
if
(
str
)
{
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
ret
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
,
NULL
,
NULL
);
}
return
ret
;
}
SECURITY_STATUS
SEC_ENTRY
thunk_AcquireCredentialsHandleW
(
SEC_WCHAR
*
pszPrincipal
,
SEC_WCHAR
*
pszPackage
,
ULONG
fCredentialsUse
,
PLUID
pvLogonID
,
PVOID
pAuthData
,
SEC_GET_KEY_FN
pGetKeyFn
,
...
...
@@ -70,15 +82,14 @@ SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleW(
pvGetKeyArgument
,
phCredential
,
ptsExpiry
);
if
(
pszPackage
)
{
PSTR
principal
,
package
;
char
*
principal
,
*
package
;
principal
=
SECUR32_AllocMultiByteFromWide
(
pszPrincipal
);
package
=
SECUR32_AllocMultiByteFromWide
(
pszPackage
);
principal
=
strdupWA
(
pszPrincipal
);
package
=
strdupWA
(
pszPackage
);
ret
=
AcquireCredentialsHandleA
(
principal
,
package
,
fCredentialsUse
,
pvLogonID
,
pAuthData
,
pGetKeyFn
,
pvGetKeyArgument
,
phCredential
,
ptsExpiry
);
heap_free
(
principal
);
heap_free
(
package
);
pvLogonID
,
pAuthData
,
pGetKeyFn
,
pvGetKeyArgument
,
phCredential
,
ptsExpiry
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
principal
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
package
);
}
else
ret
=
SEC_E_SECPKG_NOT_FOUND
;
...
...
@@ -103,24 +114,20 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesA(
{
if
(
package
->
provider
->
fnTableW
.
QueryCredentialsAttributesW
)
{
ret
=
package
->
provider
->
fnTableW
.
QueryCredentialsAttributesW
(
cred
,
ulAttribute
,
pBuffer
);
ret
=
package
->
provider
->
fnTableW
.
QueryCredentialsAttributesW
(
cred
,
ulAttribute
,
pBuffer
);
if
(
ret
==
SEC_E_OK
)
{
switch
(
ulAttribute
)
{
case
SECPKG_CRED_ATTR_NAMES
:
{
PSecPkgCredentials_NamesW
names
=
(
PSecPkgCredentials_NamesW
)
pBuffer
;
PSecPkgCredentials_NamesW
names
=
(
PSecPkgCredentials_NamesW
)
pBuffer
;
SEC_WCHAR
*
oldUser
=
names
->
sUserName
;
if
(
oldUser
)
{
names
->
sUserName
=
(
PWSTR
)
SECUR32_AllocMultiByteFromWide
(
oldUser
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldUser
);
names
->
sUserName
=
(
WCHAR
*
)
strdupWA
(
oldUser
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldUser
);
}
break
;
}
...
...
@@ -141,6 +148,18 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesA(
return
ret
;
}
static
WCHAR
*
strdupAW
(
const
char
*
str
)
{
WCHAR
*
ret
=
NULL
;
if
(
str
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
if
((
ret
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
);
}
return
ret
;
}
SECURITY_STATUS
SEC_ENTRY
thunk_QueryCredentialsAttributesW
(
PCredHandle
phCredential
,
ULONG
ulAttribute
,
void
*
pBuffer
)
{
...
...
@@ -156,24 +175,20 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesW(
{
if
(
package
->
provider
->
fnTableA
.
QueryCredentialsAttributesA
)
{
ret
=
package
->
provider
->
fnTableA
.
QueryCredentialsAttributesA
(
cred
,
ulAttribute
,
pBuffer
);
ret
=
package
->
provider
->
fnTableA
.
QueryCredentialsAttributesA
(
cred
,
ulAttribute
,
pBuffer
);
if
(
ret
==
SEC_E_OK
)
{
switch
(
ulAttribute
)
{
case
SECPKG_CRED_ATTR_NAMES
:
{
PSecPkgCredentials_NamesA
names
=
(
PSecPkgCredentials_NamesA
)
pBuffer
;
PSecPkgCredentials_NamesA
names
=
(
PSecPkgCredentials_NamesA
)
pBuffer
;
SEC_CHAR
*
oldUser
=
names
->
sUserName
;
if
(
oldUser
)
{
names
->
sUserName
=
(
PSTR
)
SECUR32_AllocWideFromMultiByte
(
oldUser
);
package
->
provider
->
fnTableA
.
FreeContextBuffer
(
oldUser
);
names
->
sUserName
=
(
char
*
)
strdupAW
(
oldUser
);
package
->
provider
->
fnTableA
.
FreeContextBuffer
(
oldUser
);
}
break
;
}
...
...
@@ -254,13 +269,13 @@ SECURITY_STATUS SEC_ENTRY thunk_InitializeSecurityContextW(
{
if
(
package
->
provider
->
fnTableA
.
InitializeSecurityContextA
)
{
PSTR
target
=
SECUR32_AllocMultiByteFromWide
(
pszTargetName
);
char
*
target
=
strdupWA
(
pszTargetName
);
ret
=
package
->
provider
->
fnTableA
.
InitializeSecurityContextA
(
phCredential
,
phContext
,
target
,
fContextReq
,
Reserved1
,
TargetDataRep
,
pInput
,
Reserved2
,
phNewContext
,
pOutput
,
pfContextAttr
,
ptsExpiry
);
heap_free
(
target
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
target
);
}
else
ret
=
SEC_E_UNSUPPORTED_FUNCTION
;
...
...
@@ -332,14 +347,14 @@ SECURITY_STATUS SEC_ENTRY thunk_AddCredentialsW(PCredHandle hCredentials,
{
if
(
package
->
provider
->
fnTableA
.
AddCredentialsA
)
{
PSTR
szPrincipal
=
SECUR32_AllocMultiByteFromWide
(
pszPrincipal
);
PSTR
szPackage
=
SECUR32_AllocMultiByteFromWide
(
pszPackage
);
char
*
szPrincipal
=
strdupWA
(
pszPrincipal
);
char
*
szPackage
=
strdupWA
(
pszPackage
);
ret
=
package
->
provider
->
fnTableA
.
AddCredentialsA
(
cred
,
szPrincipal
,
szPackage
,
fCredentialUse
,
pAuthData
,
pGetKeyFn
,
pvGetKeyArgument
,
ptsExpiry
);
heap_free
(
szPrincipal
);
heap_free
(
szPackage
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
szPrincipal
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
szPackage
);
}
else
ret
=
SEC_E_UNSUPPORTED_FUNCTION
;
...
...
@@ -373,17 +388,15 @@ static PSecPkgInfoA _copyPackageInfoFlatWToA(const SecPkgInfoW *infoW)
NULL
,
0
,
NULL
,
NULL
);
bytesNeeded
+=
commentLen
;
}
ret
=
heap_alloc
(
bytesNeeded
);
if
(
ret
)
if
((
ret
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
bytesNeeded
)))
{
PSTR
nextString
=
(
PSTR
)((
PBYTE
)
ret
+
sizeof
(
SecPkgInfoA
)
);
char
*
nextString
=
(
char
*
)
ret
+
sizeof
(
SecPkgInfoA
);
memcpy
(
ret
,
infoW
,
sizeof
(
SecPkgInfoA
));
if
(
infoW
->
Name
)
{
ret
->
Name
=
nextString
;
WideCharToMultiByte
(
CP_ACP
,
0
,
infoW
->
Name
,
-
1
,
nextString
,
nameLen
,
NULL
,
NULL
);
WideCharToMultiByte
(
CP_ACP
,
0
,
infoW
->
Name
,
-
1
,
nextString
,
nameLen
,
NULL
,
NULL
);
nextString
+=
nameLen
;
}
else
...
...
@@ -391,8 +404,7 @@ static PSecPkgInfoA _copyPackageInfoFlatWToA(const SecPkgInfoW *infoW)
if
(
infoW
->
Comment
)
{
ret
->
Comment
=
nextString
;
WideCharToMultiByte
(
CP_ACP
,
0
,
infoW
->
Comment
,
-
1
,
nextString
,
nameLen
,
NULL
,
NULL
);
WideCharToMultiByte
(
CP_ACP
,
0
,
infoW
->
Comment
,
-
1
,
nextString
,
nameLen
,
NULL
,
NULL
);
}
else
ret
->
Comment
=
NULL
;
...
...
@@ -419,22 +431,19 @@ static SECURITY_STATUS thunk_ContextAttributesWToA(SecurePackage *package,
if
(
oldUser
)
{
names
->
sUserName
=
(
PWSTR
)
SECUR32_AllocMultiByteFromWide
(
oldUser
);
names
->
sUserName
=
(
WCHAR
*
)
strdupWA
(
oldUser
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldUser
);
}
break
;
}
case
SECPKG_ATTR_AUTHORITY
:
{
PSecPkgContext_AuthorityW
names
=
(
PSecPkgContext_AuthorityW
)
pBuffer
;
PSecPkgContext_AuthorityW
names
=
(
PSecPkgContext_AuthorityW
)
pBuffer
;
SEC_WCHAR
*
oldAuth
=
names
->
sAuthorityName
;
if
(
oldAuth
)
{
names
->
sAuthorityName
=
(
PWSTR
)
SECUR32_AllocMultiByteFromWide
(
oldAuth
);
names
->
sAuthorityName
=
(
WCHAR
*
)
strdupWA
(
oldAuth
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldAuth
);
}
break
;
...
...
@@ -447,24 +456,19 @@ static SECURITY_STATUS thunk_ContextAttributesWToA(SecurePackage *package,
if
(
oldSigAlgName
)
{
info
->
sSignatureAlgorithmName
=
(
PWSTR
)
SECUR32_AllocMultiByteFromWide
(
oldSigAlgName
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldSigAlgName
);
info
->
sSignatureAlgorithmName
=
(
WCHAR
*
)
strdupWA
(
oldSigAlgName
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldSigAlgName
);
}
if
(
oldEncAlgName
)
{
info
->
sEncryptAlgorithmName
=
(
PWSTR
)
SECUR32_AllocMultiByteFromWide
(
oldEncAlgName
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldEncAlgName
);
info
->
sEncryptAlgorithmName
=
(
WCHAR
*
)
strdupWA
(
oldEncAlgName
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldEncAlgName
);
}
break
;
}
case
SECPKG_ATTR_PACKAGE_INFO
:
{
PSecPkgContext_PackageInfoW
info
=
(
PSecPkgContext_PackageInfoW
)
pBuffer
;
PSecPkgContext_PackageInfoW
info
=
(
PSecPkgContext_PackageInfoW
)
pBuffer
;
PSecPkgInfoW
oldPkgInfo
=
info
->
PackageInfo
;
if
(
oldPkgInfo
)
...
...
@@ -477,8 +481,7 @@ static SECURITY_STATUS thunk_ContextAttributesWToA(SecurePackage *package,
}
case
SECPKG_ATTR_NEGOTIATION_INFO
:
{
PSecPkgContext_NegotiationInfoW
info
=
(
PSecPkgContext_NegotiationInfoW
)
pBuffer
;
PSecPkgContext_NegotiationInfoW
info
=
(
PSecPkgContext_NegotiationInfoW
)
pBuffer
;
PSecPkgInfoW
oldPkgInfo
=
info
->
PackageInfo
;
if
(
oldPkgInfo
)
...
...
@@ -491,35 +494,30 @@ static SECURITY_STATUS thunk_ContextAttributesWToA(SecurePackage *package,
}
case
SECPKG_ATTR_NATIVE_NAMES
:
{
PSecPkgContext_NativeNamesW
names
=
(
PSecPkgContext_NativeNamesW
)
pBuffer
;
PWSTR
oldClient
=
names
->
sClientName
;
PWSTR
oldServer
=
names
->
sServerName
;
PSecPkgContext_NativeNamesW
names
=
(
PSecPkgContext_NativeNamesW
)
pBuffer
;
WCHAR
*
oldClient
=
names
->
sClientName
;
WCHAR
*
oldServer
=
names
->
sServerName
;
if
(
oldClient
)
{
names
->
sClientName
=
(
PWSTR
)
SECUR32_AllocMultiByteFromWide
(
oldClient
);
names
->
sClientName
=
(
WCHAR
*
)
strdupWA
(
oldClient
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldClient
);
}
if
(
oldServer
)
{
names
->
sServerName
=
(
PWSTR
)
SECUR32_AllocMultiByteFromWide
(
oldServer
);
names
->
sServerName
=
(
WCHAR
*
)
strdupWA
(
oldServer
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldServer
);
}
break
;
}
case
SECPKG_ATTR_CREDENTIAL_NAME
:
{
PSecPkgContext_CredentialNameW
name
=
(
PSecPkgContext_CredentialNameW
)
pBuffer
;
PWSTR
oldCred
=
name
->
sCredentialName
;
PSecPkgContext_CredentialNameW
name
=
(
PSecPkgContext_CredentialNameW
)
pBuffer
;
WCHAR
*
oldCred
=
name
->
sCredentialName
;
if
(
oldCred
)
{
name
->
sCredentialName
=
(
PWSTR
)
SECUR32_AllocMultiByteFromWide
(
oldCred
);
name
->
sCredentialName
=
(
WCHAR
*
)
strdupWA
(
oldCred
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldCred
);
}
break
;
...
...
@@ -560,11 +558,9 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryContextAttributesA(PCtxtHandle phContext,
{
if
(
package
->
provider
->
fnTableW
.
QueryContextAttributesW
)
{
ret
=
package
->
provider
->
fnTableW
.
QueryContextAttributesW
(
ctxt
,
ulAttribute
,
pBuffer
);
ret
=
package
->
provider
->
fnTableW
.
QueryContextAttributesW
(
ctxt
,
ulAttribute
,
pBuffer
);
if
(
ret
==
SEC_E_OK
)
ret
=
thunk_ContextAttributesWToA
(
package
,
ulAttribute
,
pBuffer
);
ret
=
thunk_ContextAttributesWToA
(
package
,
ulAttribute
,
pBuffer
);
}
else
ret
=
SEC_E_UNSUPPORTED_FUNCTION
;
...
...
@@ -588,27 +584,23 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(const SecPkgInfoA *infoA)
if
(
infoA
->
Name
)
{
nameLen
=
MultiByteToWideChar
(
CP_ACP
,
0
,
infoA
->
Name
,
-
1
,
NULL
,
0
);
nameLen
=
MultiByteToWideChar
(
CP_ACP
,
0
,
infoA
->
Name
,
-
1
,
NULL
,
0
);
bytesNeeded
+=
nameLen
*
sizeof
(
WCHAR
);
}
if
(
infoA
->
Comment
)
{
commentLen
=
MultiByteToWideChar
(
CP_ACP
,
0
,
infoA
->
Comment
,
-
1
,
NULL
,
0
);
commentLen
=
MultiByteToWideChar
(
CP_ACP
,
0
,
infoA
->
Comment
,
-
1
,
NULL
,
0
);
bytesNeeded
+=
commentLen
*
sizeof
(
WCHAR
);
}
ret
=
heap_alloc
(
bytesNeeded
);
if
(
ret
)
if
((
ret
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
bytesNeeded
)))
{
PWSTR
nextString
=
(
PWSTR
)((
PBYTE
)
ret
+
sizeof
(
SecPkgInfoW
)
);
WCHAR
*
nextString
=
(
WCHAR
*
)(
char
*
)
ret
+
sizeof
(
SecPkgInfoW
);
memcpy
(
ret
,
infoA
,
sizeof
(
SecPkgInfoA
));
if
(
infoA
->
Name
)
{
ret
->
Name
=
nextString
;
MultiByteToWideChar
(
CP_ACP
,
0
,
infoA
->
Name
,
-
1
,
nextString
,
nameLen
);
MultiByteToWideChar
(
CP_ACP
,
0
,
infoA
->
Name
,
-
1
,
nextString
,
nameLen
);
nextString
+=
nameLen
;
}
else
...
...
@@ -616,8 +608,7 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(const SecPkgInfoA *infoA)
if
(
infoA
->
Comment
)
{
ret
->
Comment
=
nextString
;
MultiByteToWideChar
(
CP_ACP
,
0
,
infoA
->
Comment
,
-
1
,
nextString
,
commentLen
);
MultiByteToWideChar
(
CP_ACP
,
0
,
infoA
->
Comment
,
-
1
,
nextString
,
commentLen
);
}
else
ret
->
Comment
=
NULL
;
...
...
@@ -644,22 +635,19 @@ static SECURITY_STATUS thunk_ContextAttributesAToW(SecurePackage *package,
if
(
oldUser
)
{
names
->
sUserName
=
(
PSTR
)
SECUR32_AllocWideFromMultiByte
(
oldUser
);
names
->
sUserName
=
(
char
*
)
strdupAW
(
oldUser
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldUser
);
}
break
;
}
case
SECPKG_ATTR_AUTHORITY
:
{
PSecPkgContext_AuthorityA
names
=
(
PSecPkgContext_AuthorityA
)
pBuffer
;
PSecPkgContext_AuthorityA
names
=
(
PSecPkgContext_AuthorityA
)
pBuffer
;
SEC_CHAR
*
oldAuth
=
names
->
sAuthorityName
;
if
(
oldAuth
)
{
names
->
sAuthorityName
=
(
PSTR
)
SECUR32_AllocWideFromMultiByte
(
oldAuth
);
names
->
sAuthorityName
=
(
char
*
)
strdupAW
(
oldAuth
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldAuth
);
}
break
;
...
...
@@ -672,25 +660,19 @@ static SECURITY_STATUS thunk_ContextAttributesAToW(SecurePackage *package,
if
(
oldSigAlgName
)
{
info
->
sSignatureAlgorithmName
=
(
PSTR
)
SECUR32_AllocWideFromMultiByte
(
oldSigAlgName
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldSigAlgName
);
info
->
sSignatureAlgorithmName
=
(
char
*
)
strdupAW
(
oldSigAlgName
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldSigAlgName
);
}
if
(
oldEncAlgName
)
{
info
->
sEncryptAlgorithmName
=
(
PSTR
)
SECUR32_AllocWideFromMultiByte
(
oldEncAlgName
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldEncAlgName
);
info
->
sEncryptAlgorithmName
=
(
char
*
)
strdupAW
(
oldEncAlgName
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldEncAlgName
);
}
break
;
}
case
SECPKG_ATTR_PACKAGE_INFO
:
{
PSecPkgContext_PackageInfoA
info
=
(
PSecPkgContext_PackageInfoA
)
pBuffer
;
PSecPkgContext_PackageInfoA
info
=
(
PSecPkgContext_PackageInfoA
)
pBuffer
;
PSecPkgInfoA
oldPkgInfo
=
info
->
PackageInfo
;
if
(
oldPkgInfo
)
...
...
@@ -703,8 +685,7 @@ static SECURITY_STATUS thunk_ContextAttributesAToW(SecurePackage *package,
}
case
SECPKG_ATTR_NEGOTIATION_INFO
:
{
PSecPkgContext_NegotiationInfoA
info
=
(
PSecPkgContext_NegotiationInfoA
)
pBuffer
;
PSecPkgContext_NegotiationInfoA
info
=
(
PSecPkgContext_NegotiationInfoA
)
pBuffer
;
PSecPkgInfoA
oldPkgInfo
=
info
->
PackageInfo
;
if
(
oldPkgInfo
)
...
...
@@ -717,35 +698,30 @@ static SECURITY_STATUS thunk_ContextAttributesAToW(SecurePackage *package,
}
case
SECPKG_ATTR_NATIVE_NAMES
:
{
PSecPkgContext_NativeNamesA
names
=
(
PSecPkgContext_NativeNamesA
)
pBuffer
;
PSTR
oldClient
=
names
->
sClientName
;
PSTR
oldServer
=
names
->
sServerName
;
PSecPkgContext_NativeNamesA
names
=
(
PSecPkgContext_NativeNamesA
)
pBuffer
;
char
*
oldClient
=
names
->
sClientName
;
char
*
oldServer
=
names
->
sServerName
;
if
(
oldClient
)
{
names
->
sClientName
=
(
PSTR
)
SECUR32_AllocWideFromMultiByte
(
oldClient
);
names
->
sClientName
=
(
char
*
)
strdupAW
(
oldClient
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldClient
);
}
if
(
oldServer
)
{
names
->
sServerName
=
(
PSTR
)
SECUR32_AllocWideFromMultiByte
(
oldServer
);
names
->
sServerName
=
(
char
*
)
strdupAW
(
oldServer
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldServer
);
}
break
;
}
case
SECPKG_ATTR_CREDENTIAL_NAME
:
{
PSecPkgContext_CredentialNameA
name
=
(
PSecPkgContext_CredentialNameA
)
pBuffer
;
PSTR
oldCred
=
name
->
sCredentialName
;
PSecPkgContext_CredentialNameA
name
=
(
PSecPkgContext_CredentialNameA
)
pBuffer
;
char
*
oldCred
=
name
->
sCredentialName
;
if
(
oldCred
)
{
name
->
sCredentialName
=
(
PSTR
)
SECUR32_AllocWideFromMultiByte
(
oldCred
);
name
->
sCredentialName
=
(
char
*
)
strdupAW
(
oldCred
);
package
->
provider
->
fnTableW
.
FreeContextBuffer
(
oldCred
);
}
break
;
...
...
@@ -786,11 +762,9 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryContextAttributesW(PCtxtHandle phContext,
{
if
(
package
->
provider
->
fnTableA
.
QueryContextAttributesA
)
{
ret
=
package
->
provider
->
fnTableA
.
QueryContextAttributesA
(
ctxt
,
ulAttribute
,
pBuffer
);
ret
=
package
->
provider
->
fnTableA
.
QueryContextAttributesA
(
ctxt
,
ulAttribute
,
pBuffer
);
if
(
ret
==
SEC_E_OK
)
ret
=
thunk_ContextAttributesAToW
(
package
,
ulAttribute
,
pBuffer
);
ret
=
thunk_ContextAttributesAToW
(
package
,
ulAttribute
,
pBuffer
);
}
else
ret
=
SEC_E_UNSUPPORTED_FUNCTION
;
...
...
@@ -819,11 +793,9 @@ SECURITY_STATUS SEC_ENTRY thunk_SetContextAttributesA(PCtxtHandle phContext,
if
(
package
->
provider
->
fnTableW
.
SetContextAttributesW
)
{
/* TODO: gotta validate size too! */
ret
=
thunk_ContextAttributesWToA
(
package
,
ulAttribute
,
pBuffer
);
ret
=
thunk_ContextAttributesWToA
(
package
,
ulAttribute
,
pBuffer
);
if
(
ret
==
SEC_E_OK
)
ret
=
package
->
provider
->
fnTableW
.
SetContextAttributesW
(
ctxt
,
ulAttribute
,
pBuffer
,
cbBuffer
);
ret
=
package
->
provider
->
fnTableW
.
SetContextAttributesW
(
ctxt
,
ulAttribute
,
pBuffer
,
cbBuffer
);
}
else
ret
=
SEC_E_UNSUPPORTED_FUNCTION
;
...
...
@@ -852,11 +824,9 @@ SECURITY_STATUS SEC_ENTRY thunk_SetContextAttributesW(PCtxtHandle phContext,
if
(
package
->
provider
->
fnTableA
.
SetContextAttributesA
)
{
/* TODO: gotta validate size too! */
ret
=
thunk_ContextAttributesAToW
(
package
,
ulAttribute
,
pBuffer
);
ret
=
thunk_ContextAttributesAToW
(
package
,
ulAttribute
,
pBuffer
);
if
(
ret
==
SEC_E_OK
)
ret
=
package
->
provider
->
fnTableA
.
SetContextAttributesA
(
ctxt
,
ulAttribute
,
pBuffer
,
cbBuffer
);
ret
=
package
->
provider
->
fnTableA
.
SetContextAttributesA
(
ctxt
,
ulAttribute
,
pBuffer
,
cbBuffer
);
}
else
ret
=
SEC_E_UNSUPPORTED_FUNCTION
;
...
...
@@ -876,11 +846,9 @@ SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextA(
SECURITY_STATUS
ret
;
UNICODE_STRING
package
;
TRACE
(
"%s %p %p %p
\n
"
,
debugstr_a
(
pszPackage
),
pPackedContext
,
Token
,
phContext
);
TRACE
(
"%s %p %p %p
\n
"
,
debugstr_a
(
pszPackage
),
pPackedContext
,
Token
,
phContext
);
RtlCreateUnicodeStringFromAsciiz
(
&
package
,
pszPackage
);
ret
=
ImportSecurityContextW
(
package
.
Buffer
,
pPackedContext
,
Token
,
phContext
);
ret
=
ImportSecurityContextW
(
package
.
Buffer
,
pPackedContext
,
Token
,
phContext
);
RtlFreeUnicodeString
(
&
package
);
return
ret
;
}
...
...
@@ -890,11 +858,10 @@ SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextW(
PCtxtHandle
phContext
)
{
SECURITY_STATUS
ret
;
PSTR
package
=
SECUR32_AllocMultiByteFromWide
(
pszPackage
);
char
*
package
=
strdupWA
(
pszPackage
);
TRACE
(
"%s %p %p %p
\n
"
,
debugstr_w
(
pszPackage
),
pPackedContext
,
Token
,
phContext
);
TRACE
(
"%s %p %p %p
\n
"
,
debugstr_w
(
pszPackage
),
pPackedContext
,
Token
,
phContext
);
ret
=
ImportSecurityContextA
(
package
,
pPackedContext
,
Token
,
phContext
);
heap_free
(
package
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
package
);
return
ret
;
}
dlls/secur32/wrapper.c
View file @
fbd30fff
...
...
@@ -18,8 +18,10 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "winnls.h"
#include "sspi.h"
...
...
@@ -32,8 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(secur32);
* phSec->dwUpper) and a copy of realHandle (stored in phSec->dwLower).
* SecHandle is equivalent to both a CredHandle and a CtxtHandle.
*/
static
SECURITY_STATUS
SECUR32_makeSecHandle
(
PSecHandle
phSec
,
SecurePackage
*
package
,
PSecHandle
realHandle
)
static
SECURITY_STATUS
make_sec_handle
(
PSecHandle
phSec
,
SecurePackage
*
package
,
PSecHandle
realHandle
)
{
SECURITY_STATUS
ret
;
...
...
@@ -41,8 +42,7 @@ static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
if
(
phSec
&&
package
&&
realHandle
)
{
PSecHandle
newSec
=
heap_alloc
(
sizeof
(
SecHandle
));
PSecHandle
newSec
=
malloc
(
sizeof
(
*
newSec
));
if
(
newSec
)
{
*
newSec
=
*
realHandle
;
...
...
@@ -87,7 +87,7 @@ SECURITY_STATUS WINAPI AcquireCredentialsHandleA(
ptsExpiry
);
if
(
ret
==
SEC_E_OK
)
{
ret
=
SECUR32_makeSecH
andle
(
phCredential
,
package
,
&
myCred
);
ret
=
make_sec_h
andle
(
phCredential
,
package
,
&
myCred
);
if
(
ret
!=
SEC_E_OK
)
package
->
provider
->
fnTableW
.
FreeCredentialsHandle
(
&
myCred
);
...
...
@@ -133,7 +133,7 @@ SECURITY_STATUS WINAPI AcquireCredentialsHandleW(
ptsExpiry
);
if
(
ret
==
SEC_E_OK
)
{
ret
=
SECUR32_makeSecH
andle
(
phCredential
,
package
,
&
myCred
);
ret
=
make_sec_h
andle
(
phCredential
,
package
,
&
myCred
);
if
(
ret
!=
SEC_E_OK
)
package
->
provider
->
fnTableW
.
FreeCredentialsHandle
(
&
myCred
);
...
...
@@ -169,7 +169,7 @@ SECURITY_STATUS WINAPI FreeCredentialsHandle(
ret
=
package
->
provider
->
fnTableW
.
FreeCredentialsHandle
(
cred
);
else
ret
=
SEC_E_INVALID_HANDLE
;
heap_
free
(
cred
);
free
(
cred
);
}
else
ret
=
SEC_E_INVALID_HANDLE
;
...
...
@@ -287,7 +287,7 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA(
phNewContext
&&
phNewContext
!=
phContext
)
{
SECURITY_STATUS
ret2
;
ret2
=
SECUR32_makeSecH
andle
(
phNewContext
,
package
,
&
myCtxt
);
ret2
=
make_sec_h
andle
(
phNewContext
,
package
,
&
myCtxt
);
if
(
ret2
!=
SEC_E_OK
)
package
->
provider
->
fnTableA
.
DeleteSecurityContext
(
&
myCtxt
);
}
...
...
@@ -351,7 +351,7 @@ SECURITY_STATUS WINAPI InitializeSecurityContextW(
phNewContext
&&
phNewContext
!=
phContext
)
{
SECURITY_STATUS
ret2
;
ret2
=
SECUR32_makeSecH
andle
(
phNewContext
,
package
,
&
myCtxt
);
ret2
=
make_sec_h
andle
(
phNewContext
,
package
,
&
myCtxt
);
if
(
ret2
!=
SEC_E_OK
)
package
->
provider
->
fnTableW
.
DeleteSecurityContext
(
&
myCtxt
);
}
...
...
@@ -395,7 +395,7 @@ SECURITY_STATUS WINAPI AcceptSecurityContext(
myCtxt
.
dwUpper
=
realCtxt
->
dwUpper
;
myCtxt
.
dwLower
=
realCtxt
->
dwLower
;
}
ret
=
package
->
provider
->
fnTableW
.
AcceptSecurityContext
(
cred
,
phContext
?
&
myCtxt
:
NULL
,
pInput
,
fContextReq
,
TargetDataRep
,
&
myCtxt
,
pOutput
,
pfContextAttr
,
ptsExpiry
);
...
...
@@ -403,7 +403,7 @@ SECURITY_STATUS WINAPI AcceptSecurityContext(
phNewContext
&&
phNewContext
!=
phContext
)
{
SECURITY_STATUS
ret2
;
ret2
=
SECUR32_makeSecH
andle
(
phNewContext
,
package
,
&
myCtxt
);
ret2
=
make_sec_h
andle
(
phNewContext
,
package
,
&
myCtxt
);
if
(
ret2
!=
SEC_E_OK
)
package
->
provider
->
fnTableW
.
DeleteSecurityContext
(
&
myCtxt
);
...
...
@@ -468,7 +468,7 @@ SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
ret
=
package
->
provider
->
fnTableW
.
DeleteSecurityContext
(
ctxt
);
else
ret
=
SEC_E_INVALID_HANDLE
;
heap_
free
(
ctxt
);
free
(
ctxt
);
}
else
ret
=
SEC_E_INVALID_HANDLE
;
...
...
@@ -690,7 +690,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
PSecPkgInfoA
*
ppPackageInfo
)
{
SECURITY_STATUS
ret
;
TRACE
(
"%s %p
\n
"
,
debugstr_a
(
pszPackageName
),
ppPackageInfo
);
if
(
pszPackageName
)
{
...
...
@@ -713,8 +713,8 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
package
->
infoW
.
Comment
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
bytesNeeded
+=
commentLen
;
}
*
ppPackageInfo
=
heap_alloc
(
bytesNeeded
);
if
(
*
ppPackageInfo
)
/* freed with FreeContextBuffer */
if
(
(
*
ppPackageInfo
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
bytesNeeded
))
)
{
PSTR
nextString
=
(
PSTR
)((
PBYTE
)
*
ppPackageInfo
+
sizeof
(
SecPkgInfoA
));
...
...
@@ -775,8 +775,8 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
commentLen
=
lstrlenW
(
package
->
infoW
.
Comment
)
+
1
;
bytesNeeded
+=
commentLen
*
sizeof
(
WCHAR
);
}
*
ppPackageInfo
=
heap_alloc
(
bytesNeeded
);
if
(
*
ppPackageInfo
)
/* freed with FreeContextBuffer */
if
(
(
*
ppPackageInfo
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
bytesNeeded
))
)
{
PWSTR
nextString
=
(
PWSTR
)((
PBYTE
)
*
ppPackageInfo
+
sizeof
(
SecPkgInfoW
));
...
...
@@ -845,7 +845,7 @@ SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
{
SECURITY_STATUS
ret
;
SecurePackage
*
package
=
SECUR32_findPackageA
(
pszPackage
);
TRACE
(
"%s %p %p %p
\n
"
,
debugstr_a
(
pszPackage
),
pPackedContext
,
Token
,
phContext
);
if
(
package
&&
package
->
provider
)
...
...
@@ -858,7 +858,7 @@ SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
pszPackage
,
pPackedContext
,
Token
,
&
myCtxt
);
if
(
ret
==
SEC_E_OK
)
{
ret
=
SECUR32_makeSecH
andle
(
phContext
,
package
,
&
myCtxt
);
ret
=
make_sec_h
andle
(
phContext
,
package
,
&
myCtxt
);
if
(
ret
!=
SEC_E_OK
)
package
->
provider
->
fnTableW
.
DeleteSecurityContext
(
&
myCtxt
);
}
...
...
@@ -893,7 +893,7 @@ SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage,
pszPackage
,
pPackedContext
,
Token
,
&
myCtxt
);
if
(
ret
==
SEC_E_OK
)
{
ret
=
SECUR32_makeSecH
andle
(
phContext
,
package
,
&
myCtxt
);
ret
=
make_sec_h
andle
(
phContext
,
package
,
&
myCtxt
);
if
(
ret
!=
SEC_E_OK
)
package
->
provider
->
fnTableW
.
DeleteSecurityContext
(
&
myCtxt
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment