Author: ekohl
Date: Mon Jul 19 20:27:36 2010
New Revision: 48121
URL:
http://svn.reactos.org/svn/reactos?rev=48121&view=rev
Log:
[ADVAPI32]
LookupAccountSidA:
- Change variable prefixes according to the variable type.
- Initialize Unicode strings after the call to LookupAccountSidW because the string length
is not set properly otherwise.
Modified:
trunk/reactos/dll/win32/advapi32/sec/misc.c
Modified: trunk/reactos/dll/win32/advapi32/sec/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/sec/mis…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/sec/misc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/sec/misc.c [iso-8859-1] Mon Jul 19 20:27:36 2010
@@ -906,51 +906,49 @@
PSID_NAME_USE peUse)
{
UNICODE_STRING NameW, ReferencedDomainNameW, SystemNameW;
- DWORD szName, szReferencedDomainName;
+ LPWSTR NameBuffer = NULL;
+ LPWSTR ReferencedDomainNameBuffer = NULL;
+ DWORD dwName, dwReferencedDomainName;
BOOL Ret;
/*
* save the buffer sizes the caller passed to us, as they may get modified and
* we require the original values when converting back to ansi
*/
- szName = *cchName;
- szReferencedDomainName = *cchReferencedDomainName;
+ dwName = *cchName;
+ dwReferencedDomainName = *cchReferencedDomainName;
/*
* allocate buffers for the unicode strings to receive
*/
- if(szName > 0)
+ if(dwName > 0)
{
- NameW.Length = 0;
- NameW.MaximumLength = szName * sizeof(WCHAR);
- NameW.Buffer = (PWSTR)LocalAlloc(LMEM_FIXED, NameW.MaximumLength);
- if(NameW.Buffer == NULL)
+ NameBuffer = (PWSTR)LocalAlloc(LMEM_FIXED, dwName);
+ if(NameBuffer == NULL)
{
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
}
else
- NameW.Buffer = NULL;
-
- if(szReferencedDomainName > 0)
+ NameBuffer = NULL;
+
+ if(dwReferencedDomainName > 0)
{
- ReferencedDomainNameW.Length = 0;
- ReferencedDomainNameW.MaximumLength = szReferencedDomainName * sizeof(WCHAR);
- ReferencedDomainNameW.Buffer = (PWSTR)LocalAlloc(LMEM_FIXED,
ReferencedDomainNameW.MaximumLength);
- if(ReferencedDomainNameW.Buffer == NULL)
- {
- if(szName > 0)
+ ReferencedDomainNameBuffer = (PWSTR)LocalAlloc(LMEM_FIXED, dwReferencedDomainName);
+ if(ReferencedDomainNameBuffer == NULL)
+ {
+ if(dwName > 0)
{
- LocalFree(NameW.Buffer);
+ LocalFree(NameBuffer);
}
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
}
else
- ReferencedDomainNameW.Buffer = NULL;
+ ReferencedDomainNameBuffer = NULL;
/*
* convert the system name to unicode - if present
@@ -972,9 +970,9 @@
Ret = LookupAccountSidW(SystemNameW.Buffer,
lpSid,
- NameW.Buffer,
+ NameBuffer,
cchName,
- ReferencedDomainNameW.Buffer,
+ ReferencedDomainNameBuffer,
cchReferencedDomainName,
peUse);
if(Ret)
@@ -989,9 +987,10 @@
ANSI_STRING NameA;
NameA.Length = 0;
- NameA.MaximumLength = ((szName <= 0xFFFF) ? (USHORT)szName : 0xFFFF);
+ NameA.MaximumLength = ((dwName <= 0xFFFF) ? (USHORT)dwName : 0xFFFF);
NameA.Buffer = lpName;
+ RtlInitUnicodeString(&NameW, NameBuffer);
RtlUnicodeStringToAnsiString(&NameA, &NameW, FALSE);
NameA.Buffer[NameA.Length] = '\0';
}
@@ -1001,10 +1000,11 @@
ANSI_STRING ReferencedDomainNameA;
ReferencedDomainNameA.Length = 0;
- ReferencedDomainNameA.MaximumLength = ((szReferencedDomainName <= 0xFFFF) ?
- (USHORT)szReferencedDomainName : 0xFFFF);
+ ReferencedDomainNameA.MaximumLength = ((dwReferencedDomainName <= 0xFFFF) ?
+ (USHORT)dwReferencedDomainName : 0xFFFF);
ReferencedDomainNameA.Buffer = lpReferencedDomainName;
+ RtlInitUnicodeString(&ReferencedDomainNameW, ReferencedDomainNameBuffer);
RtlUnicodeStringToAnsiString(&ReferencedDomainNameA,
&ReferencedDomainNameW, FALSE);
ReferencedDomainNameA.Buffer[ReferencedDomainNameA.Length] = '\0';
}
@@ -1018,13 +1018,13 @@
{
RtlFreeUnicodeString(&SystemNameW);
}
- if(NameW.Buffer != NULL)
+ if(NameBuffer != NULL)
{
- LocalFree(NameW.Buffer);
+ LocalFree(NameBuffer);
}
- if(ReferencedDomainNameW.Buffer != NULL)
+ if(ReferencedDomainNameBuffer != NULL)
{
- LocalFree(ReferencedDomainNameW.Buffer);
+ LocalFree(ReferencedDomainNameBuffer);
}
return Ret;