Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Mayr
wine
Commits
4dfd319d
Commit
4dfd319d
authored
18 years ago
by
Eric Pouech
Committed by
Alexandre Julliard
18 years ago
Browse files
Options
Downloads
Patches
Plain Diff
advapi32: Plug a couple of memory leaks.
parent
e1fd734c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dlls/advapi32/lsa.c
+40
-32
40 additions, 32 deletions
dlls/advapi32/lsa.c
dlls/advapi32/registry.c
+16
-8
16 additions, 8 deletions
dlls/advapi32/registry.c
dlls/advapi32/tests/security.c
+4
-0
4 additions, 0 deletions
dlls/advapi32/tests/security.c
with
60 additions
and
40 deletions
dlls/advapi32/lsa.c
+
40
−
32
View file @
4dfd319d
...
...
@@ -56,15 +56,22 @@ static void dumpLsaAttributes(PLSA_OBJECT_ATTRIBUTES oa)
}
}
static
void
ADVAPI_GetDomainName
(
UNICODE_STRING
*
name
)
static
void
*
ADVAPI_GetDomainName
(
unsigned
sz
,
unsigned
ofs
)
{
HKEY
key
;
BOOL
useDefault
=
TRUE
;
LONG
ret
;
BYTE
*
ptr
;
UNICODE_STRING
*
ustr
;
if
((
ret
=
RegOpenKeyExA
(
HKEY_LOCAL_MACHINE
,
"System
\\
CurrentControlSet
\\
Services
\\
VxD
\\
VNETSUP"
,
0
,
KEY_READ
,
&
key
))
==
ERROR_SUCCESS
)
static
const
WCHAR
wVNETSUP
[]
=
{
'S'
,
'y'
,
's'
,
't'
,
'e'
,
'm'
,
'\\'
,
'C'
,
'u'
,
'r'
,
'r'
,
'e'
,
'n'
,
't'
,
'C'
,
'o'
,
'n'
,
't'
,
'r'
,
'o'
,
'l'
,
'S'
,
'e'
,
't'
,
'\\'
,
'S'
,
'e'
,
'r'
,
'v'
,
'i'
,
'c'
,
'e'
,
's'
,
'\\'
,
'V'
,
'x'
,
'D'
,
'\\'
,
'V'
,
'N'
,
'E'
,
'T'
,
'S'
,
'U'
,
'P'
,
'\0'
};
ret
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
wVNETSUP
,
0
,
KEY_READ
,
&
key
);
if
(
ret
==
ERROR_SUCCESS
)
{
DWORD
size
=
0
;
static
const
WCHAR
wg
[]
=
{
'W'
,
'o'
,
'r'
,
'k'
,
'g'
,
'r'
,
'o'
,
'u'
,
'p'
,
0
};
...
...
@@ -72,26 +79,34 @@ static void ADVAPI_GetDomainName(UNICODE_STRING * name)
ret
=
RegQueryValueExW
(
key
,
wg
,
NULL
,
NULL
,
NULL
,
&
size
);
if
(
ret
==
ERROR_MORE_DATA
||
ret
==
ERROR_SUCCESS
)
{
name
->
Buffer
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
ptr
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sz
+
size
);
if
(
!
ptr
)
return
NULL
;
ustr
=
(
UNICODE_STRING
*
)(
ptr
+
ofs
);
ustr
->
MaximumLength
=
size
;
ustr
->
Buffer
=
(
WCHAR
*
)(
ptr
+
sz
);
if
((
ret
=
RegQueryValueExW
(
key
,
wg
,
NULL
,
NULL
,
(
LPBYTE
)
name
->
Buffer
,
&
size
))
==
ERROR_SUCCESS
)
(
LPBYTE
)
ustr
->
Buffer
,
&
size
))
==
ERROR_SUCCESS
)
{
name
->
Length
=
(
USHORT
)(
size
-
sizeof
(
WCHAR
));
name
->
MaximumLength
=
(
USHORT
)
size
;
ustr
->
Length
=
(
USHORT
)(
size
-
sizeof
(
WCHAR
));
useDefault
=
FALSE
;
}
else
{
HeapFree
(
GetProcessHeap
(),
0
,
name
->
Buffer
);
name
->
Buffer
=
NULL
;
}
HeapFree
(
GetProcessHeap
(),
0
,
ptr
);
}
RegCloseKey
(
key
);
}
if
(
useDefault
)
RtlCreateUnicodeStringFromAsciiz
(
name
,
"DOMAIN"
);
{
static
const
WCHAR
wDomain
[]
=
{
'D'
,
'O'
,
'M'
,
'A'
,
'I'
,
'N'
,
'\0'
};
ptr
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sz
+
sizeof
(
wDomain
));
ustr
=
(
UNICODE_STRING
*
)(
ptr
+
ofs
);
ustr
->
MaximumLength
=
sizeof
(
wDomain
);
ustr
->
Buffer
=
(
WCHAR
*
)(
ptr
+
sz
);
ustr
->
Length
=
(
USHORT
)(
sizeof
(
wDomain
)
-
sizeof
(
WCHAR
));
memcpy
(
ustr
->
Buffer
,
wDomain
,
sizeof
(
wDomain
));
}
return
ptr
;
}
/******************************************************************************
...
...
@@ -431,10 +446,8 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
/* Only the domain name is valid for the local computer.
* All other fields are zero.
*/
PPOLICY_PRIMARY_DOMAIN_INFO
pinfo
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
POLICY_PRIMARY_DOMAIN_INFO
));
ADVAPI_GetDomainName
(
&
pinfo
->
Name
);
PPOLICY_PRIMARY_DOMAIN_INFO
pinfo
;
pinfo
=
ADVAPI_GetDomainName
(
sizeof
(
*
pinfo
),
(
char
*
)
&
pinfo
->
Name
-
(
char
*
)
pinfo
);
TRACE
(
"setting domain to %s
\n
"
,
debugstr_w
(
pinfo
->
Name
.
Buffer
));
...
...
@@ -448,28 +461,24 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
POLICY_ACCOUNT_DOMAIN_INFO
info
;
SID
sid
;
DWORD
padding
[
3
];
WCHAR
domain
[
MAX_COMPUTERNAME_LENGTH
+
1
];
};
struct
di
*
xdi
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
xdi
));
DWORD
dwSize
=
MAX_COMPUTERNAME_LENGTH
+
1
;
LPWSTR
buf
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
dwSize
*
sizeof
(
WCHAR
));
struct
di
*
xdi
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
xdi
));
xdi
->
info
.
DomainName
.
MaximumLength
=
dwSize
*
sizeof
(
WCHAR
);
if
(
GetComputerNameW
(
buf
,
&
dwSize
))
{
xdi
->
info
.
DomainName
.
Buffer
=
buf
;
xdi
->
info
.
DomainName
.
Buffer
=
xdi
->
domain
;
if
(
GetComputerNameW
(
xdi
->
info
.
DomainName
.
Buffer
,
&
dwSize
))
xdi
->
info
.
DomainName
.
Length
=
dwSize
*
sizeof
(
WCHAR
);
}
TRACE
(
"setting name to %s
\n
"
,
debugstr_w
(
xdi
->
info
.
DomainName
.
Buffer
));
xdi
->
info
.
DomainSid
=
&
(
xdi
->
sid
)
;
xdi
->
info
.
DomainSid
=
&
xdi
->
sid
;
/* read the computer SID from the registry */
if
(
!
ADVAPI_GetComputerSid
(
&
(
xdi
->
sid
))
)
if
(
!
ADVAPI_GetComputerSid
(
&
xdi
->
sid
))
{
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
HeapFree
(
GetProcessHeap
(),
0
,
xdi
);
WARN
(
"Computer SID not found
\n
"
);
...
...
@@ -487,10 +496,9 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
/* Only the domain name is valid for the local computer.
* All other fields are zero.
*/
PPOLICY_DNS_DOMAIN_INFO
pinfo
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
POLICY_DNS_DOMAIN_INFO
));
PPOLICY_DNS_DOMAIN_INFO
pinfo
;
ADVAPI_GetDomainName
(
&
pinfo
->
Name
);
pinfo
=
ADVAPI_GetDomainName
(
sizeof
(
*
pinfo
),
(
char
*
)
&
pinfo
->
Name
-
(
char
*
)
pinfo
);
TRACE
(
"setting domain to %s
\n
"
,
debugstr_w
(
pinfo
->
Name
.
Buffer
));
...
...
This diff is collapsed.
Click to expand it.
dlls/advapi32/registry.c
+
16
−
8
View file @
4dfd319d
...
...
@@ -1887,6 +1887,7 @@ LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename )
{
OBJECT_ATTRIBUTES
destkey
,
file
;
UNICODE_STRING
subkeyW
,
filenameW
;
NTSTATUS
status
;
if
(
!
(
hkey
=
get_special_root_hkey
(
hkey
)))
return
ERROR_INVALID_HANDLE
;
...
...
@@ -1906,7 +1907,9 @@ LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename )
file
.
SecurityQualityOfService
=
NULL
;
RtlDosPathNameToNtPathName_U
(
filename
,
&
filenameW
,
NULL
,
NULL
);
return
RtlNtStatusToDosError
(
NtLoadKey
(
&
destkey
,
&
file
)
);
status
=
NtLoadKey
(
&
destkey
,
&
file
);
RtlFreeUnicodeString
(
&
filenameW
);
return
RtlNtStatusToDosError
(
status
);
}
...
...
@@ -1920,17 +1923,22 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
UNICODE_STRING
subkeyW
,
filenameW
;
STRING
subkeyA
,
filenameA
;
NTSTATUS
status
;
LONG
ret
;
RtlInitAnsiString
(
&
subkeyA
,
subkey
);
RtlInitAnsiString
(
&
filenameA
,
filename
);
if
((
status
=
RtlAnsiStringToUnicodeString
(
&
subkeyW
,
&
subkeyA
,
TRUE
)))
return
RtlNtStatusToDosError
(
status
);
if
((
status
=
RtlAnsiStringToUnicodeString
(
&
filenameW
,
&
filenameA
,
TRUE
)))
return
RtlNtStatusToDosError
(
status
);
return
RegLoadKeyW
(
hkey
,
subkeyW
.
Buffer
,
filenameW
.
Buffer
);
RtlInitUnicodeString
(
&
subkeyW
,
NULL
);
RtlInitUnicodeString
(
&
filenameW
,
NULL
);
if
(
!
(
status
=
RtlAnsiStringToUnicodeString
(
&
subkeyW
,
&
subkeyA
,
TRUE
))
&&
!
(
status
=
RtlAnsiStringToUnicodeString
(
&
filenameW
,
&
filenameA
,
TRUE
)))
{
ret
=
RegLoadKeyW
(
hkey
,
subkeyW
.
Buffer
,
filenameW
.
Buffer
);
}
else
ret
=
RtlNtStatusToDosError
(
status
);
RtlFreeUnicodeString
(
&
subkeyW
);
RtlFreeUnicodeString
(
&
filenameW
);
return
ret
;
}
...
...
This diff is collapsed.
Click to expand it.
dlls/advapi32/tests/security.c
+
4
−
0
View file @
4dfd319d
...
...
@@ -100,6 +100,7 @@ static void test_str_sid(const char *str_sid)
trace
(
" %s: %s
\n
"
,
str_sid
,
temp
);
LocalFree
(
temp
);
}
LocalFree
(
psid
);
}
else
{
...
...
@@ -833,6 +834,7 @@ static void test_token_attr(void)
pConvertSidToStringSidA
(
User
->
User
.
Sid
,
&
SidString
);
trace
(
"TokenUser: %s attr: 0x%08x
\n
"
,
SidString
,
User
->
User
.
Attributes
);
LocalFree
(
SidString
);
HeapFree
(
GetProcessHeap
(),
0
,
User
);
/* privileges */
ret
=
GetTokenInformation
(
Token
,
TokenPrivileges
,
NULL
,
0
,
&
Size
);
...
...
@@ -1044,6 +1046,8 @@ static void test_LookupAccountSid(void)
"LookupAccountSidW() Expected dom_size = %u, got %u
\n
"
,
real_dom_sizeW
+
1
,
dom_sizeW
);
FreeSid
(
pUsersSid
);
pCreateWellKnownSid
=
(
fnCreateWellKnownSid
)
GetProcAddress
(
hmod
,
"CreateWellKnownSid"
);
if
(
pCreateWellKnownSid
&&
pConvertSidToStringSidA
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment