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
7abcc312
Commit
7abcc312
authored
Aug 16, 2023
by
Alex Henrie
Committed by
Alexandre Julliard
Aug 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Use CRT allocation functions.
parent
fd67d678
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
161 additions
and
162 deletions
+161
-162
advapi.c
dlls/advapi32/advapi.c
+3
-3
advapi32_misc.h
dlls/advapi32/advapi32_misc.h
+1
-2
cred.c
dlls/advapi32/cred.c
+55
-55
eventlog.c
dlls/advapi32/eventlog.c
+9
-9
lsa.c
dlls/advapi32/lsa.c
+29
-29
security.c
dlls/advapi32/security.c
+48
-48
service.c
dlls/advapi32/service.c
+16
-16
No files found.
dlls/advapi32/advapi.c
View file @
7abcc312
...
...
@@ -252,9 +252,9 @@ BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassw
ret
=
LogonUserW
(
usernameW
,
domainW
,
passwordW
,
dwLogonType
,
dwLogonProvider
,
phToken
);
done:
heap_
free
(
usernameW
);
heap_
free
(
domainW
);
heap_
free
(
passwordW
);
free
(
usernameW
);
free
(
domainW
);
free
(
passwordW
);
return
ret
;
}
...
...
dlls/advapi32/advapi32_misc.h
View file @
7abcc312
...
...
@@ -23,7 +23,6 @@
#include "ntsecapi.h"
#include "winsvc.h"
#include "winnls.h"
#include "wine/heap.h"
const
char
*
debugstr_sid
(
PSID
sid
);
BOOL
ADVAPI_IsLocalComputer
(
LPCWSTR
ServerName
);
...
...
@@ -41,7 +40,7 @@ static inline WCHAR *strdupAW( const char *src )
if
(
src
)
{
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
-
1
,
NULL
,
0
);
if
((
dst
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
-
1
,
dst
,
len
);
if
((
dst
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
-
1
,
dst
,
len
);
}
return
dst
;
}
...
...
dlls/advapi32/cred.c
View file @
7abcc312
...
...
@@ -229,7 +229,7 @@ static DWORD write_credential_blob(HKEY hkey, LPCWSTR target_name, DWORD type,
key
.
Length
=
key
.
MaximumLength
=
KEY_SIZE
;
key
.
Buffer
=
(
unsigned
char
*
)
key_data
;
encrypted_credential_blob
=
heap_
alloc
(
credential_blob_size
);
encrypted_credential_blob
=
m
alloc
(
credential_blob_size
);
if
(
!
encrypted_credential_blob
)
return
ERROR_OUTOFMEMORY
;
memcpy
(
encrypted_credential_blob
,
credential_blob
,
credential_blob_size
);
...
...
@@ -238,7 +238,7 @@ static DWORD write_credential_blob(HKEY hkey, LPCWSTR target_name, DWORD type,
SystemFunction032
(
&
data
,
&
key
);
ret
=
RegSetValueExW
(
hkey
,
L"Password"
,
0
,
REG_BINARY
,
encrypted_credential_blob
,
credential_blob_size
);
heap_
free
(
encrypted_credential_blob
);
free
(
encrypted_credential_blob
);
return
ret
;
}
...
...
@@ -320,7 +320,7 @@ static DWORD host_write_credential( const CREDENTIALW *credential, BOOL preserve
size
=
sizeof
(
*
cred
)
+
(
lstrlenW
(
credential
->
TargetName
)
+
lstrlenW
(
credential
->
UserName
)
+
2
)
*
sizeof
(
WCHAR
);
size
+=
credential
->
CredentialBlobSize
;
if
(
credential
->
Comment
)
size
+=
(
lstrlenW
(
credential
->
Comment
)
+
1
)
*
sizeof
(
WCHAR
);
if
(
!
(
cred
=
heap_
alloc
(
size
)))
if
(
!
(
cred
=
m
alloc
(
size
)))
{
CloseHandle
(
mgr
);
return
ERROR_OUTOFMEMORY
;
...
...
@@ -356,7 +356,7 @@ static DWORD host_write_credential( const CREDENTIALW *credential, BOOL preserve
else
cred
->
comment_size
=
0
;
ret
=
DeviceIoControl
(
mgr
,
IOCTL_MOUNTMGR_WRITE_CREDENTIAL
,
cred
,
size
,
NULL
,
0
,
NULL
,
NULL
);
heap_
free
(
cred
);
free
(
cred
);
CloseHandle
(
mgr
);
return
ret
?
ERROR_SUCCESS
:
GetLastError
();
...
...
@@ -435,7 +435,7 @@ static LPWSTR get_key_name_for_target(LPCWSTR target_name, DWORD type)
len
+=
ARRAY_SIZE
(
L"DomPasswd: "
);
}
key_name
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
key_name
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
key_name
)
return
NULL
;
lstrcpyW
(
key_name
,
prefix
);
...
...
@@ -463,13 +463,13 @@ static BOOL registry_credential_matches_filter(HKEY hkeyCred, LPCWSTR filter)
else
if
(
type
!=
REG_SZ
)
return
FALSE
;
target_name
=
heap_
alloc
(
count
);
target_name
=
m
alloc
(
count
);
if
(
!
target_name
)
return
FALSE
;
ret
=
RegQueryValueExW
(
hkeyCred
,
NULL
,
0
,
&
type
,
(
LPVOID
)
target_name
,
&
count
);
if
(
ret
!=
ERROR_SUCCESS
||
type
!=
REG_SZ
)
{
heap_
free
(
target_name
);
free
(
target_name
);
return
FALSE
;
}
...
...
@@ -481,7 +481,7 @@ static BOOL registry_credential_matches_filter(HKEY hkeyCred, LPCWSTR filter)
(
p
&&
!
p
[
1
]
?
p
-
filter
:
-
1
),
target_name
,
(
p
&&
!
p
[
1
]
?
p
-
filter
:
-
1
))
==
CSTR_EQUAL
;
heap_
free
(
target_name
);
free
(
target_name
);
return
ret
;
}
...
...
@@ -730,7 +730,7 @@ BOOL WINAPI CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags)
}
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
TargetName
,
-
1
,
NULL
,
0
);
TargetNameW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
TargetNameW
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
TargetNameW
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -740,7 +740,7 @@ BOOL WINAPI CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags)
ret
=
CredDeleteW
(
TargetNameW
,
Type
,
Flags
);
heap_
free
(
TargetNameW
);
free
(
TargetNameW
);
return
ret
;
}
...
...
@@ -758,7 +758,7 @@ static DWORD host_delete_credential( const WCHAR *targetname )
if
(
mgr
==
INVALID_HANDLE_VALUE
)
return
GetLastError
();
size
=
sizeof
(
*
cred
)
+
name_size
;
if
(
!
(
cred
=
heap_
alloc
(
size
)))
if
(
!
(
cred
=
m
alloc
(
size
)))
{
CloseHandle
(
mgr
);
return
ERROR_OUTOFMEMORY
;
...
...
@@ -769,7 +769,7 @@ static DWORD host_delete_credential( const WCHAR *targetname )
lstrcpyW
(
ptr
,
targetname
);
ret
=
DeviceIoControl
(
mgr
,
IOCTL_MOUNTMGR_DELETE_CREDENTIAL
,
cred
,
size
,
NULL
,
0
,
NULL
,
NULL
);
heap_
free
(
cred
);
free
(
cred
);
CloseHandle
(
mgr
);
return
ret
?
ERROR_SUCCESS
:
GetLastError
();
...
...
@@ -823,7 +823,7 @@ BOOL WINAPI CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags)
key_name
=
get_key_name_for_target
(
TargetName
,
Type
);
ret
=
RegDeleteKeyW
(
hkeyMgr
,
key_name
);
heap_
free
(
key_name
);
free
(
key_name
);
RegCloseKey
(
hkeyMgr
);
if
(
ret
!=
ERROR_SUCCESS
)
{
...
...
@@ -852,7 +852,7 @@ BOOL WINAPI CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD *Count,
if
(
Filter
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
Filter
,
-
1
,
NULL
,
0
);
FilterW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
FilterW
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
FilterW
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -865,16 +865,16 @@ BOOL WINAPI CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD *Count,
if
(
!
CredEnumerateW
(
FilterW
,
Flags
,
Count
,
&
CredentialsW
))
{
heap_
free
(
FilterW
);
free
(
FilterW
);
return
FALSE
;
}
heap_
free
(
FilterW
);
free
(
FilterW
);
len
=
*
Count
*
sizeof
(
PCREDENTIALA
);
for
(
i
=
0
;
i
<
*
Count
;
i
++
)
len
+=
convert_PCREDENTIALW_to_PCREDENTIALA
(
CredentialsW
[
i
],
NULL
,
0
);
*
Credentials
=
heap_
alloc
(
len
);
*
Credentials
=
m
alloc
(
len
);
if
(
!*
Credentials
)
{
CredFree
(
CredentialsW
);
...
...
@@ -917,7 +917,7 @@ static DWORD host_enumerate_credentials( const WCHAR *filter, CREDENTIALW **cred
if
(
mgr
==
INVALID_HANDLE_VALUE
)
return
GetLastError
();
size
=
FIELD_OFFSET
(
struct
mountmgr_credential_list
,
creds
[
CRED_LIST_COUNT
]
)
+
filter_size
+
CRED_DATA_SIZE
;
if
(
!
(
list
=
heap_
alloc
(
size
)))
if
(
!
(
list
=
m
alloc
(
size
)))
{
CloseHandle
(
mgr
);
return
ERROR_OUTOFMEMORY
;
...
...
@@ -934,7 +934,7 @@ static DWORD host_enumerate_credentials( const WCHAR *filter, CREDENTIALW **cred
if
((
ret
=
GetLastError
())
!=
ERROR_MORE_DATA
)
goto
done
;
size
=
list
->
size
+
filter_size
;
if
(
!
(
tmp
=
heap_
realloc
(
list
,
size
)))
if
(
!
(
tmp
=
realloc
(
list
,
size
)))
{
ret
=
ERROR_OUTOFMEMORY
;
goto
done
;
...
...
@@ -994,7 +994,7 @@ static DWORD host_enumerate_credentials( const WCHAR *filter, CREDENTIALW **cred
ret
=
ERROR_SUCCESS
;
done:
heap_
free
(
list
);
free
(
list
);
CloseHandle
(
mgr
);
return
ret
;
}
...
...
@@ -1044,7 +1044,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
return
FALSE
;
}
target_name
=
heap_alloc
((
target_name_len
+
1
)
*
sizeof
(
WCHAR
));
target_name
=
malloc
((
target_name_len
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
target_name
)
{
RegCloseKey
(
hkeyMgr
);
...
...
@@ -1065,7 +1065,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
ret
=
ERROR_NOT_FOUND
;
if
(
ret
!=
ERROR_SUCCESS
)
{
heap_
free
(
target_name
);
free
(
target_name
);
RegCloseKey
(
hkeyMgr
);
SetLastError
(
ret
);
return
FALSE
;
...
...
@@ -1074,7 +1074,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
if
(
ret
==
ERROR_SUCCESS
)
{
buffer
=
heap_
alloc
(
len
);
buffer
=
m
alloc
(
len
);
*
Credentials
=
(
PCREDENTIALW
*
)
buffer
;
if
(
buffer
)
{
...
...
@@ -1091,7 +1091,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
else
ret
=
ERROR_OUTOFMEMORY
;
}
heap_
free
(
target_name
);
free
(
target_name
);
RegCloseKey
(
hkeyMgr
);
if
(
ret
!=
ERROR_SUCCESS
)
...
...
@@ -1107,7 +1107,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
*/
VOID
WINAPI
CredFree
(
PVOID
Buffer
)
{
heap_
free
(
Buffer
);
free
(
Buffer
);
}
/******************************************************************************
...
...
@@ -1128,7 +1128,7 @@ BOOL WINAPI CredReadA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA *
}
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
TargetName
,
-
1
,
NULL
,
0
);
TargetNameW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
TargetNameW
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
TargetNameW
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -1138,13 +1138,13 @@ BOOL WINAPI CredReadA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA *
if
(
!
CredReadW
(
TargetNameW
,
Type
,
Flags
,
&
CredentialW
))
{
heap_
free
(
TargetNameW
);
free
(
TargetNameW
);
return
FALSE
;
}
heap_
free
(
TargetNameW
);
free
(
TargetNameW
);
len
=
convert_PCREDENTIALW_to_PCREDENTIALA
(
CredentialW
,
NULL
,
0
);
*
Credential
=
heap_
alloc
(
len
);
*
Credential
=
m
alloc
(
len
);
if
(
!*
Credential
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -1170,7 +1170,7 @@ static DWORD host_read_credential( const WCHAR *targetname, CREDENTIALW **ret_cr
if
(
mgr
==
INVALID_HANDLE_VALUE
)
return
GetLastError
();
size_in
=
sizeof
(
*
cred_in
)
+
size_name
;
if
(
!
(
cred_in
=
heap_
alloc
(
size_in
)))
if
(
!
(
cred_in
=
m
alloc
(
size_in
)))
{
CloseHandle
(
mgr
);
return
ERROR_OUTOFMEMORY
;
...
...
@@ -1181,14 +1181,14 @@ static DWORD host_read_credential( const WCHAR *targetname, CREDENTIALW **ret_cr
lstrcpyW
(
ptr
,
targetname
);
size_out
=
256
;
if
(
!
(
cred_out
=
heap_
alloc
(
size_out
)))
goto
done
;
if
(
!
(
cred_out
=
m
alloc
(
size_out
)))
goto
done
;
for
(;;)
{
ret
=
DeviceIoControl
(
mgr
,
IOCTL_MOUNTMGR_READ_CREDENTIAL
,
cred_in
,
size_in
,
cred_out
,
size_out
,
NULL
,
NULL
);
if
(
ret
||
(
err
=
GetLastError
())
!=
ERROR_MORE_DATA
)
break
;
size_out
*=
2
;
if
(
!
(
tmp
=
heap_
realloc
(
cred_out
,
size_out
)))
goto
done
;
if
(
!
(
tmp
=
realloc
(
cred_out
,
size_out
)))
goto
done
;
cred_out
=
tmp
;
}
...
...
@@ -1198,7 +1198,7 @@ static DWORD host_read_credential( const WCHAR *targetname, CREDENTIALW **ret_cr
DWORD
size
=
sizeof
(
*
credential
)
+
cred_out
->
targetname_size
+
cred_out
->
username_size
+
cred_out
->
comment_size
+
cred_out
->
blob_size
;
if
(
!
(
credential
=
heap_alloc_zero
(
size
)))
if
(
!
(
credential
=
calloc
(
1
,
size
)))
{
err
=
ERROR_OUTOFMEMORY
;
goto
done
;
...
...
@@ -1231,8 +1231,8 @@ static DWORD host_read_credential( const WCHAR *targetname, CREDENTIALW **ret_cr
}
done:
heap_
free
(
cred_in
);
heap_
free
(
cred_out
);
free
(
cred_in
);
free
(
cred_out
);
CloseHandle
(
mgr
);
return
err
;
}
...
...
@@ -1300,7 +1300,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW
key_name
=
get_key_name_for_target
(
TargetName
,
Type
);
ret
=
RegOpenKeyExW
(
hkeyMgr
,
key_name
,
0
,
KEY_QUERY_VALUE
,
&
hkeyCred
);
heap_
free
(
key_name
);
free
(
key_name
);
if
(
ret
!=
ERROR_SUCCESS
)
{
TRACE
(
"credentials for target name %s not found
\n
"
,
debugstr_w
(
TargetName
));
...
...
@@ -1312,7 +1312,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW
ret
=
registry_read_credential
(
hkeyCred
,
NULL
,
key_data
,
NULL
,
&
len
);
if
(
ret
==
ERROR_SUCCESS
)
{
*
Credential
=
heap_
alloc
(
len
);
*
Credential
=
m
alloc
(
len
);
if
(
*
Credential
)
{
len
=
sizeof
(
**
Credential
);
...
...
@@ -1375,7 +1375,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf
if
(
TargetInformation
->
PackageName
)
len
+=
MultiByteToWideChar
(
CP_ACP
,
0
,
TargetInformation
->
PackageName
,
-
1
,
NULL
,
0
)
*
sizeof
(
WCHAR
);
TargetInformationW
=
heap_
alloc
(
len
);
TargetInformationW
=
m
alloc
(
len
);
if
(
!
TargetInformationW
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -1446,7 +1446,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf
ret
=
CredReadDomainCredentialsW
(
TargetInformationW
,
Flags
,
Size
,
&
CredentialsW
);
heap_
free
(
TargetInformationW
);
free
(
TargetInformationW
);
if
(
ret
)
{
...
...
@@ -1457,7 +1457,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf
for
(
i
=
0
;
i
<
*
Size
;
i
++
)
len
+=
convert_PCREDENTIALW_to_PCREDENTIALA
(
CredentialsW
[
i
],
NULL
,
0
);
*
Credentials
=
heap_
alloc
(
len
);
*
Credentials
=
m
alloc
(
len
);
if
(
!*
Credentials
)
{
CredFree
(
CredentialsW
);
...
...
@@ -1519,7 +1519,7 @@ BOOL WINAPI CredWriteA(PCREDENTIALA Credential, DWORD Flags)
}
len
=
convert_PCREDENTIALA_to_PCREDENTIALW
(
Credential
,
NULL
,
0
);
CredentialW
=
heap_
alloc
(
len
);
CredentialW
=
m
alloc
(
len
);
if
(
!
CredentialW
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -1530,7 +1530,7 @@ BOOL WINAPI CredWriteA(PCREDENTIALA Credential, DWORD Flags)
ret
=
CredWriteW
(
CredentialW
,
Flags
);
heap_
free
(
CredentialW
);
free
(
CredentialW
);
return
ret
;
}
...
...
@@ -1621,7 +1621,7 @@ BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags)
ret
=
RegCreateKeyExW
(
hkeyMgr
,
key_name
,
0
,
NULL
,
Credential
->
Persist
==
CRED_PERSIST_SESSION
?
REG_OPTION_VOLATILE
:
REG_OPTION_NON_VOLATILE
,
KEY_READ
|
KEY_WRITE
,
NULL
,
&
hkeyCred
,
NULL
);
heap_
free
(
key_name
);
free
(
key_name
);
if
(
ret
!=
ERROR_SUCCESS
)
{
TRACE
(
"credentials for target name %s not found
\n
"
,
...
...
@@ -1677,13 +1677,13 @@ BOOL WINAPI CredMarshalCredentialA( CRED_MARSHAL_TYPE type, PVOID cred, LPSTR *o
if
((
ret
=
CredMarshalCredentialW
(
type
,
cred
,
&
outW
)))
{
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
outW
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
(
*
out
=
heap_
alloc
(
len
)))
if
(
!
(
*
out
=
m
alloc
(
len
)))
{
heap_
free
(
outW
);
free
(
outW
);
return
FALSE
;
}
WideCharToMultiByte
(
CP_ACP
,
0
,
outW
,
-
1
,
*
out
,
len
,
NULL
,
NULL
);
heap_
free
(
outW
);
free
(
outW
);
}
return
ret
;
}
...
...
@@ -1741,7 +1741,7 @@ BOOL WINAPI CredMarshalCredentialW( CRED_MARSHAL_TYPE type, PVOID cred, LPWSTR *
case
CertCredential
:
{
size
=
(
sizeof
(
cert
->
rgbHashOfCert
)
+
2
)
*
4
/
3
;
if
(
!
(
p
=
heap_
alloc
(
(
size
+
4
)
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
if
(
!
(
p
=
m
alloc
(
(
size
+
4
)
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
p
[
0
]
=
'@'
;
p
[
1
]
=
'@'
;
p
[
2
]
=
'A'
+
type
;
...
...
@@ -1753,7 +1753,7 @@ BOOL WINAPI CredMarshalCredentialW( CRED_MARSHAL_TYPE type, PVOID cred, LPWSTR *
{
len
=
lstrlenW
(
target
->
UserName
);
size
=
(
sizeof
(
DWORD
)
+
len
*
sizeof
(
WCHAR
)
+
2
)
*
4
/
3
;
if
(
!
(
p
=
heap_
alloc
(
(
size
+
4
)
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
if
(
!
(
p
=
m
alloc
(
(
size
+
4
)
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
p
[
0
]
=
'@'
;
p
[
1
]
=
'@'
;
p
[
2
]
=
'A'
+
type
;
...
...
@@ -1786,11 +1786,11 @@ BOOL WINAPI CredUnmarshalCredentialA( LPCSTR cred, PCRED_MARSHAL_TYPE type, PVOI
if
(
cred
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
cred
,
-
1
,
NULL
,
0
);
if
(
!
(
credW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
if
(
!
(
credW
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
MultiByteToWideChar
(
CP_ACP
,
0
,
cred
,
-
1
,
credW
,
len
);
}
ret
=
CredUnmarshalCredentialW
(
credW
,
type
,
out
);
heap_
free
(
credW
);
free
(
credW
);
return
ret
;
}
...
...
@@ -1876,7 +1876,7 @@ BOOL WINAPI CredUnmarshalCredentialW( LPCWSTR cred, PCRED_MARSHAL_TYPE type, PVO
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
!
(
cert
=
heap_
alloc
(
sizeof
(
*
cert
)
)))
return
FALSE
;
if
(
!
(
cert
=
m
alloc
(
sizeof
(
*
cert
)
)))
return
FALSE
;
memcpy
(
cert
->
rgbHashOfCert
,
hash
,
sizeof
(
cert
->
rgbHashOfCert
)
);
cert
->
cbSize
=
sizeof
(
*
cert
);
*
out
=
cert
;
...
...
@@ -1894,10 +1894,10 @@ BOOL WINAPI CredUnmarshalCredentialW( LPCWSTR cred, PCRED_MARSHAL_TYPE type, PVO
return
FALSE
;
}
buflen
=
sizeof
(
*
target
)
+
size
+
sizeof
(
WCHAR
);
if
(
!
(
target
=
heap_
alloc
(
buflen
)))
return
FALSE
;
if
(
!
(
target
=
m
alloc
(
buflen
)))
return
FALSE
;
if
(
!
cred_decode
(
cred
+
9
,
len
-
6
,
(
char
*
)(
target
+
1
)
))
{
heap_
free
(
target
);
free
(
target
);
return
FALSE
;
}
target
->
UserName
=
(
WCHAR
*
)(
target
+
1
);
...
...
@@ -1973,11 +1973,11 @@ BOOL WINAPI CredIsMarshaledCredentialA(LPCSTR name)
if
(
name
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
NULL
,
0
);
nameW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
nameW
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
nameW
,
len
);
}
res
=
CredIsMarshaledCredentialW
(
nameW
);
heap_
free
(
nameW
);
free
(
nameW
);
return
res
;
}
dlls/advapi32/eventlog.c
View file @
7abcc312
...
...
@@ -58,7 +58,7 @@ BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
backupW
=
strdupAW
(
lpBackupFileName
);
ret
=
BackupEventLogW
(
hEventLog
,
backupW
);
heap_
free
(
backupW
);
free
(
backupW
);
return
ret
;
}
...
...
@@ -115,7 +115,7 @@ BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
backupW
=
strdupAW
(
lpBackupFileName
);
ret
=
ClearEventLogW
(
hEventLog
,
backupW
);
heap_
free
(
backupW
);
free
(
backupW
);
return
ret
;
}
...
...
@@ -394,8 +394,8 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
uncnameW
=
strdupAW
(
lpUNCServerName
);
filenameW
=
strdupAW
(
lpFileName
);
handle
=
OpenBackupEventLogW
(
uncnameW
,
filenameW
);
heap_
free
(
uncnameW
);
heap_
free
(
filenameW
);
free
(
uncnameW
);
free
(
filenameW
);
return
handle
;
}
...
...
@@ -453,8 +453,8 @@ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source )
uncnameW
=
strdupAW
(
uncname
);
sourceW
=
strdupAW
(
source
);
handle
=
OpenEventLogW
(
uncnameW
,
sourceW
);
heap_
free
(
uncnameW
);
heap_
free
(
sourceW
);
free
(
uncnameW
);
free
(
sourceW
);
return
handle
;
}
...
...
@@ -608,7 +608,7 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d
if
(
wNumStrings
==
0
)
return
TRUE
;
if
(
!
lpStrings
)
return
TRUE
;
wideStrArray
=
heap_alloc
(
sizeof
(
LPWSTR
)
*
wNumStrings
);
wideStrArray
=
malloc
(
sizeof
(
WCHAR
*
)
*
wNumStrings
);
for
(
i
=
0
;
i
<
wNumStrings
;
i
++
)
{
RtlCreateUnicodeStringFromAsciiz
(
&
str
,
lpStrings
[
i
]);
...
...
@@ -617,8 +617,8 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d
ret
=
ReportEventW
(
hEventLog
,
wType
,
wCategory
,
dwEventID
,
lpUserSid
,
wNumStrings
,
dwDataSize
,
(
LPCWSTR
*
)
wideStrArray
,
lpRawData
);
for
(
i
=
0
;
i
<
wNumStrings
;
i
++
)
heap_free
(
wideStrArray
[
i
]
);
heap_
free
(
wideStrArray
);
free
(
wideStrArray
[
i
]
);
free
(
wideStrArray
);
return
ret
;
}
...
...
dlls/advapi32/lsa.c
View file @
7abcc312
...
...
@@ -103,7 +103,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ret
=
RegQueryValueExW
(
key
,
L"Workgroup"
,
NULL
,
NULL
,
NULL
,
&
size
);
if
(
ret
==
ERROR_MORE_DATA
||
ret
==
ERROR_SUCCESS
)
{
ptr
=
heap_alloc_zero
(
sz
+
size
);
ptr
=
calloc
(
1
,
sz
+
size
);
if
(
!
ptr
)
return
NULL
;
ustr
=
(
UNICODE_STRING
*
)(
ptr
+
ofs
);
ustr
->
MaximumLength
=
size
;
...
...
@@ -111,7 +111,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ret
=
RegQueryValueExW
(
key
,
L"Workgroup"
,
NULL
,
NULL
,
(
LPBYTE
)
ustr
->
Buffer
,
&
size
);
if
(
ret
!=
ERROR_SUCCESS
)
{
heap_
free
(
ptr
);
free
(
ptr
);
ptr
=
NULL
;
}
else
ustr
->
Length
=
size
-
sizeof
(
WCHAR
);
...
...
@@ -120,7 +120,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
}
if
(
!
ptr
)
{
ptr
=
heap_alloc_zero
(
sz
+
sizeof
(
L"DOMAIN"
));
ptr
=
calloc
(
1
,
sz
+
sizeof
(
L"DOMAIN"
));
if
(
!
ptr
)
return
NULL
;
ustr
=
(
UNICODE_STRING
*
)(
ptr
+
ofs
);
ustr
->
MaximumLength
=
sizeof
(
L"DOMAIN"
);
...
...
@@ -144,7 +144,7 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
if
(
GetUserNameW
(
NULL
,
&
user_size
)
||
GetLastError
()
!=
ERROR_INSUFFICIENT_BUFFER
)
return
STATUS_UNSUCCESSFUL
;
user
=
heap_
alloc
(
sizeof
(
*
user
)
+
user_size
*
sizeof
(
WCHAR
));
user
=
m
alloc
(
sizeof
(
*
user
)
+
user_size
*
sizeof
(
WCHAR
));
if
(
!
user
)
return
STATUS_NO_MEMORY
;
user
->
Buffer
=
(
WCHAR
*
)(
user
+
1
);
...
...
@@ -152,7 +152,7 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
user
->
Length
=
user
->
MaximumLength
-
sizeof
(
WCHAR
);
if
(
!
GetUserNameW
(
user
->
Buffer
,
&
user_size
))
{
heap_
free
(
user
);
free
(
user
);
return
STATUS_UNSUCCESSFUL
;
}
...
...
@@ -165,14 +165,14 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
domain_size
=
ARRAY_SIZE
(
computer
);
if
(
!
GetComputerNameW
(
computer
,
&
domain_size
))
{
heap_
free
(
user
);
free
(
user
);
return
STATUS_UNSUCCESSFUL
;
}
domain
=
heap_
alloc
(
sizeof
(
*
domain
)
+
(
domain_size
+
1
)
*
sizeof
(
WCHAR
));
domain
=
m
alloc
(
sizeof
(
*
domain
)
+
(
domain_size
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
domain
)
{
heap_
free
(
user
);
free
(
user
);
return
STATUS_NO_MEMORY
;
}
...
...
@@ -362,7 +362,7 @@ NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
{
TRACE
(
"(%p)
\n
"
,
Buffer
);
heap_
free
(
Buffer
);
free
(
Buffer
);
return
STATUS_SUCCESS
;
}
...
...
@@ -497,22 +497,22 @@ NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count,
TRACE
(
"mapped %lu out of %lu
\n
"
,
mapped
,
count
);
size
=
sizeof
(
LSA_TRANSLATED_SID2
)
*
count
+
sid_size_total
;
if
(
!
(
*
sids
=
heap_
alloc
(
size
)))
return
STATUS_NO_MEMORY
;
if
(
!
(
*
sids
=
m
alloc
(
size
)))
return
STATUS_NO_MEMORY
;
sid
=
(
SID
*
)(
*
sids
+
count
);
/* use maximum domain count */
if
(
!
(
*
domains
=
heap_alloc
(
sizeof
(
LSA_REFERENCED_DOMAIN_LIST
)
+
sizeof
(
LSA_TRUST_INFORMATION
)
*
count
+
sid_size_total
+
domainname_size_total
*
sizeof
(
WCHAR
))))
if
(
!
(
*
domains
=
malloc
(
sizeof
(
LSA_REFERENCED_DOMAIN_LIST
)
+
sizeof
(
LSA_TRUST_INFORMATION
)
*
count
+
sid_size_total
+
domainname_size_total
*
sizeof
(
WCHAR
))))
{
heap_
free
(
*
sids
);
free
(
*
sids
);
return
STATUS_NO_MEMORY
;
}
(
*
domains
)
->
Entries
=
0
;
(
*
domains
)
->
Domains
=
(
LSA_TRUST_INFORMATION
*
)((
char
*
)
*
domains
+
sizeof
(
LSA_REFERENCED_DOMAIN_LIST
));
domain_data
=
(
char
*
)(
*
domains
)
->
Domains
+
sizeof
(
LSA_TRUST_INFORMATION
)
*
count
;
domain
.
Buffer
=
heap_alloc
(
domain_size_max
*
sizeof
(
WCHAR
));
domain
.
Buffer
=
malloc
(
domain_size_max
*
sizeof
(
WCHAR
));
for
(
i
=
0
;
i
<
count
;
i
++
)
{
domain
.
Length
=
domain_size_max
*
sizeof
(
WCHAR
);
...
...
@@ -541,7 +541,7 @@ NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count,
}
}
}
heap_
free
(
domain
.
Buffer
);
free
(
domain
.
Buffer
);
if
(
mapped
==
count
)
return
STATUS_SUCCESS
;
if
(
mapped
>
0
&&
mapped
<
count
)
return
STATUS_SOME_NOT_MAPPED
;
...
...
@@ -584,13 +584,13 @@ NTSTATUS WINAPI LsaLookupSids(
/* this length does not include actual string length yet */
name_fullsize
=
sizeof
(
LSA_TRANSLATED_NAME
)
*
Count
;
if
(
!
(
*
Names
=
heap_
alloc
(
name_fullsize
)))
return
STATUS_NO_MEMORY
;
if
(
!
(
*
Names
=
m
alloc
(
name_fullsize
)))
return
STATUS_NO_MEMORY
;
/* maximum count of stored domain infos is Count, allocate it like that cause really needed
count could only be computed after sid data is retrieved */
domain_fullsize
=
sizeof
(
LSA_REFERENCED_DOMAIN_LIST
)
+
sizeof
(
LSA_TRUST_INFORMATION
)
*
Count
;
if
(
!
(
*
ReferencedDomains
=
heap_
alloc
(
domain_fullsize
)))
if
(
!
(
*
ReferencedDomains
=
m
alloc
(
domain_fullsize
)))
{
heap_
free
(
*
Names
);
free
(
*
Names
);
return
STATUS_NO_MEMORY
;
}
(
*
ReferencedDomains
)
->
Entries
=
0
;
...
...
@@ -633,7 +633,7 @@ NTSTATUS WINAPI LsaLookupSids(
domain_fullsize
+=
domain_size
*
sizeof
(
WCHAR
);
/* get domain SID size too */
name
=
heap_
alloc
(
domain_size
*
sizeof
(
WCHAR
));
name
=
m
alloc
(
domain_size
*
sizeof
(
WCHAR
));
*
name
=
0
;
LookupAccountSidW
(
NULL
,
Sids
[
i
],
NULL
,
&
name_size
,
name
,
&
domain_size
,
&
use
);
...
...
@@ -644,7 +644,7 @@ NTSTATUS WINAPI LsaLookupSids(
lookup_name
(
&
domain
,
NULL
,
&
sid_size
,
NULL
,
&
domain_size
,
&
use
,
&
handled
);
domain_fullsize
+=
sid_size
;
heap_
free
(
name
);
free
(
name
);
}
else
{
...
...
@@ -665,10 +665,10 @@ NTSTATUS WINAPI LsaLookupSids(
}
/* now we have full length needed for both */
*
Names
=
heap_
realloc
(
*
Names
,
name_fullsize
);
*
Names
=
realloc
(
*
Names
,
name_fullsize
);
name_buffer
=
(
WCHAR
*
)((
char
*
)
*
Names
+
sizeof
(
LSA_TRANSLATED_NAME
)
*
Count
);
*
ReferencedDomains
=
heap_
realloc
(
*
ReferencedDomains
,
domain_fullsize
);
*
ReferencedDomains
=
realloc
(
*
ReferencedDomains
,
domain_fullsize
);
/* fix pointer after reallocation */
(
*
ReferencedDomains
)
->
Domains
=
(
LSA_TRUST_INFORMATION
*
)((
char
*
)
*
ReferencedDomains
+
sizeof
(
LSA_REFERENCED_DOMAIN_LIST
));
domain_data
=
(
char
*
)(
*
ReferencedDomains
)
->
Domains
+
sizeof
(
LSA_TRUST_INFORMATION
)
*
Count
;
...
...
@@ -697,13 +697,13 @@ NTSTATUS WINAPI LsaLookupSids(
domain
.
MaximumLength
=
sizeof
(
WCHAR
);
}
domain
.
Buffer
=
heap_
alloc
(
domain
.
MaximumLength
);
domain
.
Buffer
=
m
alloc
(
domain
.
MaximumLength
);
LookupAccountSidW
(
NULL
,
Sids
[
i
],
(
*
Names
)[
i
].
Name
.
Buffer
,
&
name_size
,
domain
.
Buffer
,
&
domain_size
,
&
use
);
(
*
Names
)[
i
].
Use
=
use
;
(
*
Names
)[
i
].
DomainIndex
=
lsa_reflist_add_domain
(
*
ReferencedDomains
,
&
domain
,
&
domain_data
);
heap_
free
(
domain
.
Buffer
);
free
(
domain
.
Buffer
);
}
else
if
(
ConvertSidToStringSidW
(
Sids
[
i
],
&
strsid
))
{
...
...
@@ -813,7 +813,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
{
case
PolicyAuditEventsInformation
:
/* 2 */
{
PPOLICY_AUDIT_EVENTS_INFO
p
=
heap_alloc_zero
(
sizeof
(
POLICY_AUDIT_EVENTS_INFO
));
PPOLICY_AUDIT_EVENTS_INFO
p
=
calloc
(
1
,
sizeof
(
POLICY_AUDIT_EVENTS_INFO
));
p
->
AuditingMode
=
FALSE
;
/* no auditing */
*
Buffer
=
p
;
}
...
...
@@ -843,7 +843,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
};
DWORD
dwSize
=
MAX_COMPUTERNAME_LENGTH
+
1
;
struct
di
*
xdi
=
heap_alloc_zero
(
sizeof
(
*
xdi
));
struct
di
*
xdi
=
calloc
(
1
,
sizeof
(
*
xdi
));
xdi
->
info
.
DomainName
.
MaximumLength
=
dwSize
*
sizeof
(
WCHAR
);
xdi
->
info
.
DomainName
.
Buffer
=
xdi
->
domain
;
...
...
@@ -856,7 +856,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
if
(
!
ADVAPI_GetComputerSid
(
&
xdi
->
sid
))
{
heap_
free
(
xdi
);
free
(
xdi
);
WARN
(
"Computer SID not found
\n
"
);
...
...
@@ -889,7 +889,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
}
computer_sid
;
DWORD
dwSize
;
xdi
=
heap_alloc_zero
(
sizeof
(
*
xdi
));
xdi
=
calloc
(
1
,
sizeof
(
*
xdi
));
if
(
!
xdi
)
return
STATUS_NO_MEMORY
;
dwSize
=
256
;
...
...
@@ -1156,7 +1156,7 @@ NTSTATUS WINAPI LsaLookupPrivilegeName(LSA_HANDLE handle, LUID *luid, LSA_UNICOD
return
STATUS_NO_SUCH_PRIVILEGE
;
length
=
lstrlenW
(
privnameW
);
*
name
=
heap_
alloc
(
sizeof
(
**
name
)
+
(
length
+
1
)
*
sizeof
(
WCHAR
));
*
name
=
m
alloc
(
sizeof
(
**
name
)
+
(
length
+
1
)
*
sizeof
(
WCHAR
));
if
(
!*
name
)
return
STATUS_NO_MEMORY
;
...
...
dlls/advapi32/security.c
View file @
7abcc312
...
...
@@ -234,12 +234,12 @@ BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
if
(
!
ServerName
||
!
ServerName
[
0
])
return
TRUE
;
buf
=
heap_
alloc
(
dwSize
*
sizeof
(
WCHAR
));
buf
=
m
alloc
(
dwSize
*
sizeof
(
WCHAR
));
Result
=
GetComputerNameW
(
buf
,
&
dwSize
);
if
(
Result
&&
(
ServerName
[
0
]
==
'\\'
)
&&
(
ServerName
[
1
]
==
'\\'
))
ServerName
+=
2
;
Result
=
Result
&&
!
wcscmp
(
ServerName
,
buf
);
heap_
free
(
buf
);
free
(
buf
);
return
Result
;
}
...
...
@@ -599,7 +599,7 @@ LookupPrivilegeNameA( LPCSTR lpSystemName, PLUID lpLuid, LPSTR lpName,
ret
=
LookupPrivilegeNameW
(
lpSystemNameW
.
Buffer
,
lpLuid
,
NULL
,
&
wLen
);
if
(
!
ret
&&
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
)
{
LPWSTR
lpNameW
=
heap_
alloc
(
wLen
*
sizeof
(
WCHAR
));
LPWSTR
lpNameW
=
m
alloc
(
wLen
*
sizeof
(
WCHAR
));
ret
=
LookupPrivilegeNameW
(
lpSystemNameW
.
Buffer
,
lpLuid
,
lpNameW
,
&
wLen
);
...
...
@@ -628,7 +628,7 @@ LookupPrivilegeNameA( LPCSTR lpSystemName, PLUID lpLuid, LPSTR lpName,
*
cchName
=
len
-
1
;
}
}
heap_
free
(
lpNameW
);
free
(
lpNameW
);
}
RtlFreeUnicodeString
(
&
lpSystemNameW
);
return
ret
;
...
...
@@ -726,7 +726,7 @@ GetFileSecurityA( LPCSTR lpFileName,
name
=
strdupAW
(
lpFileName
);
r
=
GetFileSecurityW
(
name
,
RequestedInformation
,
pSecurityDescriptor
,
nLength
,
lpnLengthNeeded
);
heap_
free
(
name
);
free
(
name
);
return
r
;
}
...
...
@@ -754,9 +754,9 @@ LookupAccountSidA(
systemW
=
strdupAW
(
system
);
if
(
account
)
accountW
=
heap_
alloc
(
accountSizeW
*
sizeof
(
WCHAR
)
);
accountW
=
m
alloc
(
accountSizeW
*
sizeof
(
WCHAR
)
);
if
(
domain
)
domainW
=
heap_
alloc
(
domainSizeW
*
sizeof
(
WCHAR
)
);
domainW
=
m
alloc
(
domainSizeW
*
sizeof
(
WCHAR
)
);
r
=
LookupAccountSidW
(
systemW
,
sid
,
accountW
,
&
accountSizeW
,
domainW
,
&
domainSizeW
,
name_use
);
...
...
@@ -781,9 +781,9 @@ LookupAccountSidA(
*
domainSize
=
domainSizeW
+
1
;
}
heap_
free
(
systemW
);
heap_
free
(
accountW
);
heap_
free
(
domainW
);
free
(
systemW
);
free
(
accountW
);
free
(
domainW
);
return
r
;
}
...
...
@@ -867,7 +867,7 @@ LookupAccountSidW(
DWORD
size
=
MAX_COMPUTERNAME_LENGTH
+
1
;
BOOL
result
;
computer_name
=
heap_
alloc
(
size
*
sizeof
(
WCHAR
));
computer_name
=
m
alloc
(
size
*
sizeof
(
WCHAR
));
result
=
GetComputerNameW
(
computer_name
,
&
size
);
if
(
result
)
{
...
...
@@ -921,7 +921,7 @@ LookupAccountSidW(
break
;
case
1000
:
/* first user account */
size
=
UNLEN
+
1
;
account_name
=
heap_
alloc
(
size
*
sizeof
(
WCHAR
));
account_name
=
m
alloc
(
size
*
sizeof
(
WCHAR
));
if
(
GetUserNameW
(
account_name
,
&
size
))
ac
=
account_name
;
else
...
...
@@ -968,14 +968,14 @@ LookupAccountSidW(
else
*
accountSize
=
ac_len
+
1
;
heap_
free
(
account_name
);
heap_
free
(
computer_name
);
free
(
account_name
);
free
(
computer_name
);
if
(
status
)
*
name_use
=
use
;
return
status
;
}
heap_
free
(
account_name
);
heap_
free
(
computer_name
);
free
(
account_name
);
free
(
computer_name
);
SetLastError
(
ERROR_NONE_MAPPED
);
return
FALSE
;
}
...
...
@@ -1009,7 +1009,7 @@ BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
name
=
strdupAW
(
lpFileName
);
r
=
SetFileSecurityW
(
name
,
RequestedInformation
,
pSecurityDescriptor
);
heap_
free
(
name
);
free
(
name
);
return
r
;
}
...
...
@@ -1079,7 +1079,7 @@ LookupAccountNameA(
RtlCreateUnicodeStringFromAsciiz
(
&
lpAccountW
,
account
);
if
(
ReferencedDomainName
)
lpReferencedDomainNameW
=
heap_
alloc
(
*
cbReferencedDomainName
*
sizeof
(
WCHAR
));
lpReferencedDomainNameW
=
m
alloc
(
*
cbReferencedDomainName
*
sizeof
(
WCHAR
));
ret
=
LookupAccountNameW
(
lpSystemW
.
Buffer
,
lpAccountW
.
Buffer
,
sid
,
cbSid
,
lpReferencedDomainNameW
,
cbReferencedDomainName
,
name_use
);
...
...
@@ -1092,7 +1092,7 @@ LookupAccountNameA(
RtlFreeUnicodeString
(
&
lpSystemW
);
RtlFreeUnicodeString
(
&
lpAccountW
);
heap_
free
(
lpReferencedDomainNameW
);
free
(
lpReferencedDomainNameW
);
return
ret
;
}
...
...
@@ -1279,7 +1279,7 @@ BOOL lookup_local_wellknown_name( const LSA_UNICODE_STRING *account_and_domain,
{
DWORD
len
,
sidLen
=
SECURITY_MAX_SID_SIZE
;
if
(
!
(
pSid
=
heap_
alloc
(
sidLen
)))
return
FALSE
;
if
(
!
(
pSid
=
m
alloc
(
sidLen
)))
return
FALSE
;
if
((
ret
=
CreateWellKnownSid
(
ACCOUNT_SIDS
[
i
].
type
,
NULL
,
pSid
,
&
sidLen
)))
{
...
...
@@ -1311,7 +1311,7 @@ BOOL lookup_local_wellknown_name( const LSA_UNICODE_STRING *account_and_domain,
if
(
ret
)
*
peUse
=
ACCOUNT_SIDS
[
i
].
name_use
;
heap_
free
(
pSid
);
free
(
pSid
);
*
handled
=
TRUE
;
return
ret
;
}
...
...
@@ -1336,7 +1336,7 @@ BOOL lookup_local_user_name( const LSA_UNICODE_STRING *account_and_domain,
/* Let the current Unix user id masquerade as first Windows user account */
nameLen
=
UNLEN
+
1
;
if
(
!
(
userName
=
heap_
alloc
(
nameLen
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
if
(
!
(
userName
=
m
alloc
(
nameLen
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
if
(
domain
.
Buffer
)
{
...
...
@@ -1367,7 +1367,7 @@ BOOL lookup_local_user_name( const LSA_UNICODE_STRING *account_and_domain,
}
}
heap_
free
(
userName
);
free
(
userName
);
return
ret
;
}
...
...
@@ -1975,7 +1975,7 @@ static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR *
if
(
objA
)
{
if
(
!
(
objW
=
heap_
alloc
(
sizeof
(
OBJECTS_AND_NAME_W
)
)))
if
(
!
(
objW
=
m
alloc
(
sizeof
(
OBJECTS_AND_NAME_W
)
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
objW
->
ObjectsPresent
=
objA
->
ObjectsPresent
;
...
...
@@ -2003,7 +2003,7 @@ static void free_trustee_name(TRUSTEE_FORM form, WCHAR *trustee_nameW)
switch
(
form
)
{
case
TRUSTEE_IS_NAME
:
heap_
free
(
trustee_nameW
);
free
(
trustee_nameW
);
break
;
case
TRUSTEE_IS_OBJECTS_AND_NAME
:
{
...
...
@@ -2011,10 +2011,10 @@ static void free_trustee_name(TRUSTEE_FORM form, WCHAR *trustee_nameW)
if
(
objW
)
{
heap_
free
(
objW
->
ptstrName
);
heap_
free
(
objW
->
InheritedObjectTypeName
);
heap_
free
(
objW
->
ObjectTypeName
);
heap_
free
(
objW
);
free
(
objW
->
ptstrName
);
free
(
objW
->
InheritedObjectTypeName
);
free
(
objW
->
ObjectTypeName
);
free
(
objW
);
}
break
;
...
...
@@ -2093,7 +2093,7 @@ DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
if
(
!
count
&&
!
OldAcl
)
return
ERROR_SUCCESS
;
pEntriesW
=
heap_
alloc
(
count
*
sizeof
(
EXPLICIT_ACCESSW
)
);
pEntriesW
=
m
alloc
(
count
*
sizeof
(
EXPLICIT_ACCESSW
)
);
if
(
!
pEntriesW
)
return
ERROR_NOT_ENOUGH_MEMORY
;
...
...
@@ -2129,7 +2129,7 @@ cleanup:
for
(
free_index
=
0
;
free_index
<
alloc_index
;
++
free_index
)
free_trustee_name
(
pEntriesW
[
free_index
].
Trustee
.
TrusteeForm
,
pEntriesW
[
free_index
].
Trustee
.
ptstrName
);
heap_
free
(
pEntriesW
);
free
(
pEntriesW
);
return
err
;
}
...
...
@@ -2154,7 +2154,7 @@ DWORD WINAPI SetEntriesInAclW( ULONG count, PEXPLICIT_ACCESSW pEntries,
return
ERROR_SUCCESS
;
/* allocate array of maximum sized sids allowed */
ppsid
=
heap_
alloc
(
count
*
(
sizeof
(
SID
*
)
+
FIELD_OFFSET
(
SID
,
SubAuthority
[
SID_MAX_SUB_AUTHORITIES
])));
ppsid
=
m
alloc
(
count
*
(
sizeof
(
SID
*
)
+
FIELD_OFFSET
(
SID
,
SubAuthority
[
SID_MAX_SUB_AUTHORITIES
])));
if
(
!
ppsid
)
return
ERROR_OUTOFMEMORY
;
...
...
@@ -2344,7 +2344,7 @@ DWORD WINAPI SetEntriesInAclW( ULONG count, PEXPLICIT_ACCESSW pEntries,
}
exit:
heap_
free
(
ppsid
);
free
(
ppsid
);
return
ret
;
}
...
...
@@ -2365,7 +2365,7 @@ DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName,
r
=
SetNamedSecurityInfoW
(
wstr
,
ObjectType
,
SecurityInfo
,
psidOwner
,
psidGroup
,
pDacl
,
pSacl
);
heap_
free
(
wstr
);
free
(
wstr
);
return
r
;
}
...
...
@@ -2565,7 +2565,7 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA(
ret
=
ConvertStringSecurityDescriptorToSecurityDescriptorW
(
StringSecurityDescriptorW
,
StringSDRevision
,
SecurityDescriptor
,
SecurityDescriptorSize
);
heap_
free
(
StringSecurityDescriptorW
);
free
(
StringSecurityDescriptorW
);
return
ret
;
}
...
...
@@ -2582,7 +2582,7 @@ BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorA(PSECURITY_DESCR
int
lenA
;
lenA
=
WideCharToMultiByte
(
CP_ACP
,
0
,
wstr
,
len
,
NULL
,
0
,
NULL
,
NULL
);
*
OutputString
=
heap_
alloc
(
lenA
);
*
OutputString
=
m
alloc
(
lenA
);
WideCharToMultiByte
(
CP_ACP
,
0
,
wstr
,
len
,
*
OutputString
,
lenA
,
NULL
,
NULL
);
LocalFree
(
wstr
);
...
...
@@ -2615,7 +2615,7 @@ BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid)
{
WCHAR
*
wStringSid
=
strdupAW
(
StringSid
);
bret
=
ConvertStringSidToSidW
(
wStringSid
,
Sid
);
heap_
free
(
wStringSid
);
free
(
wStringSid
);
}
return
bret
;
}
...
...
@@ -2691,7 +2691,7 @@ DWORD WINAPI GetNamedSecurityInfoA(LPSTR pObjectName,
r
=
GetNamedSecurityInfoW
(
wstr
,
ObjectType
,
SecurityInfo
,
ppsidOwner
,
ppsidGroup
,
ppDacl
,
ppSacl
,
ppSecurityDescriptor
);
heap_
free
(
wstr
);
free
(
wstr
);
return
r
;
}
...
...
@@ -2852,14 +2852,14 @@ static NTSTATUS combine_dacls(ACL *parent, ACL *child, ACL **result)
int
i
;
/* initialize a combined DACL containing both inherited and new ACEs */
combined
=
heap_alloc_zero
(
child
->
AclSize
+
parent
->
AclSize
);
combined
=
calloc
(
1
,
child
->
AclSize
+
parent
->
AclSize
);
if
(
!
combined
)
return
STATUS_NO_MEMORY
;
status
=
RtlCreateAcl
(
combined
,
parent
->
AclSize
+
child
->
AclSize
,
ACL_REVISION
);
if
(
status
!=
STATUS_SUCCESS
)
{
heap_
free
(
combined
);
free
(
combined
);
return
status
;
}
...
...
@@ -2934,19 +2934,19 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
if
(
status
!=
STATUS_BUFFER_TOO_SMALL
)
return
RtlNtStatusToDosError
(
status
);
psd
=
heap_
alloc
(
size
);
psd
=
m
alloc
(
size
);
if
(
!
psd
)
return
ERROR_NOT_ENOUGH_MEMORY
;
status
=
NtQuerySecurityObject
(
handle
,
SecurityInfo
,
psd
,
size
,
&
size
);
if
(
status
)
{
heap_
free
(
psd
);
free
(
psd
);
return
RtlNtStatusToDosError
(
status
);
}
status
=
RtlGetControlSecurityDescriptor
(
psd
,
&
control
,
&
rev
);
heap_
free
(
psd
);
free
(
psd
);
if
(
status
)
return
RtlNtStatusToDosError
(
status
);
/* TODO: copy some control flags to new sd */
...
...
@@ -2958,14 +2958,14 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
if
(
status
!=
STATUS_INFO_LENGTH_MISMATCH
)
return
RtlNtStatusToDosError
(
status
);
name_info
=
heap_
alloc
(
size
);
name_info
=
m
alloc
(
size
);
if
(
!
name_info
)
return
ERROR_NOT_ENOUGH_MEMORY
;
status
=
NtQueryObject
(
handle
,
ObjectNameInformation
,
name_info
,
size
,
NULL
);
if
(
status
)
{
heap_
free
(
name_info
);
free
(
name_info
);
return
RtlNtStatusToDosError
(
status
);
}
...
...
@@ -2992,7 +2992,7 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
status
=
NtOpenFile
(
&
parent
,
READ_CONTROL
|
SYNCHRONIZE
,
&
attr
,
&
io
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
FILE_OPEN_FOR_BACKUP_INTENT
);
heap_
free
(
name_info
);
free
(
name_info
);
if
(
!
status
)
{
err
=
GetSecurityInfo
(
parent
,
SE_FILE_OBJECT
,
DACL_SECURITY_INFORMATION
,
...
...
@@ -3009,7 +3009,7 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
}
}
else
heap_
free
(
name_info
);
free
(
name_info
);
}
}
...
...
@@ -3029,7 +3029,7 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
break
;
}
if
(
dacl
!=
pDacl
)
heap_
free
(
dacl
);
free
(
dacl
);
return
RtlNtStatusToDosError
(
status
);
}
...
...
dlls/advapi32/service.c
View file @
7abcc312
...
...
@@ -79,7 +79,7 @@ EnumServicesStatusA( SC_HANDLE hmngr, DWORD type, DWORD state, LPENUM_SERVICE_ST
}
sz
=
max
(
2
*
size
,
sizeof
(
*
servicesW
)
);
if
(
!
(
servicesW
=
heap_
alloc
(
sz
)))
if
(
!
(
servicesW
=
m
alloc
(
sz
)))
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
...
...
@@ -113,7 +113,7 @@ EnumServicesStatusA( SC_HANDLE hmngr, DWORD type, DWORD state, LPENUM_SERVICE_ST
ret
=
TRUE
;
done:
heap_
free
(
servicesW
);
free
(
servicesW
);
return
ret
;
}
...
...
@@ -150,7 +150,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
&&
GetLastError
()
!=
ERROR_MORE_DATA
)
return
FALSE
;
if
(
!
(
status_ex
=
heap_
alloc
(
alloc_size
)))
if
(
!
(
status_ex
=
m
alloc
(
alloc_size
)))
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
...
...
@@ -160,7 +160,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
alloc_size
,
&
alloc_size
,
&
count
,
resume_handle
,
NULL
)
&&
GetLastError
()
!=
ERROR_MORE_DATA
)
{
heap_
free
(
status_ex
);
free
(
status_ex
);
return
FALSE
;
}
...
...
@@ -198,7 +198,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
status
[
i
].
ServiceStatus
.
dwWaitHint
=
status_ex
[
i
].
ServiceStatusProcess
.
dwWaitHint
;
}
heap_
free
(
status_ex
);
free
(
status_ex
);
if
(
*
ret_size
>
size
)
{
SetLastError
(
ERROR_MORE_DATA
);
...
...
@@ -229,7 +229,7 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st
size
,
needed
,
returned
,
resume_handle
,
debugstr_a
(
group
));
sz
=
max
(
2
*
size
,
sizeof
(
*
servicesW
)
);
if
(
!
(
servicesW
=
heap_
alloc
(
sz
)))
if
(
!
(
servicesW
=
m
alloc
(
sz
)))
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
...
...
@@ -237,10 +237,10 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st
if
(
group
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
group
,
-
1
,
NULL
,
0
);
if
(
!
(
groupW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
if
(
!
(
groupW
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
heap_
free
(
servicesW
);
free
(
servicesW
);
return
FALSE
;
}
MultiByteToWideChar
(
CP_ACP
,
0
,
group
,
-
1
,
groupW
,
len
*
sizeof
(
WCHAR
)
);
...
...
@@ -275,8 +275,8 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st
ret
=
TRUE
;
done:
heap_
free
(
servicesW
);
heap_
free
(
groupW
);
free
(
servicesW
);
free
(
groupW
);
return
ret
;
}
...
...
@@ -295,7 +295,7 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName,
lpDisplayNameW
=
strdupAW
(
lpDisplayName
);
if
(
lpServiceName
)
lpServiceNameW
=
heap_
alloc
(
*
lpcchBuffer
*
sizeof
(
WCHAR
));
lpServiceNameW
=
m
alloc
(
*
lpcchBuffer
*
sizeof
(
WCHAR
));
else
lpServiceNameW
=
NULL
;
...
...
@@ -321,8 +321,8 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName,
ret
=
TRUE
;
cleanup:
heap_
free
(
lpServiceNameW
);
heap_
free
(
lpDisplayNameW
);
free
(
lpServiceNameW
);
free
(
lpDisplayNameW
);
return
ret
;
}
...
...
@@ -365,7 +365,7 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
lpServiceNameW
=
strdupAW
(
lpServiceName
);
if
(
lpDisplayName
)
lpDisplayNameW
=
heap_
alloc
(
*
lpcchBuffer
*
sizeof
(
WCHAR
));
lpDisplayNameW
=
m
alloc
(
*
lpcchBuffer
*
sizeof
(
WCHAR
));
else
lpDisplayNameW
=
NULL
;
...
...
@@ -392,8 +392,8 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
ret
=
TRUE
;
cleanup:
heap_
free
(
lpDisplayNameW
);
heap_
free
(
lpServiceNameW
);
free
(
lpDisplayNameW
);
free
(
lpServiceNameW
);
return
ret
;
}
...
...
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