mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
Fixed some wrong size calculations in GetEnvironmentStringsA().
Fixed a wrong return value in GetEnvironmentVariableA(). svn path=/trunk/; revision=2810
This commit is contained in:
parent
6c10b3528a
commit
de299abd9a
1 changed files with 6 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: env.c,v 1.12 2002/03/17 17:56:57 hbirr Exp $
|
||||
/* $Id: env.c,v 1.13 2002/04/01 22:08:20 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -72,7 +72,7 @@ GetEnvironmentVariableA (
|
|||
SetLastErrorByStatus (Status);
|
||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||
{
|
||||
return VarNameU.Length / sizeof(WCHAR) + 1;
|
||||
return VarValueU.Length / sizeof(WCHAR) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ GetEnvironmentStringsA (
|
|||
DPRINT("EnvPtr %p\n", EnvPtr);
|
||||
|
||||
/* convert unicode environment to ansi */
|
||||
UnicodeString.MaximumLength = Length + sizeof(WCHAR);
|
||||
UnicodeString.MaximumLength = Length * sizeof(WCHAR) + sizeof(WCHAR);
|
||||
UnicodeString.Buffer = EnvU;
|
||||
|
||||
AnsiString.MaximumLength = Length + 1;
|
||||
|
@ -312,16 +312,16 @@ GetEnvironmentStringsA (
|
|||
while (*(UnicodeString.Buffer))
|
||||
{
|
||||
UnicodeString.Length = wcslen (UnicodeString.Buffer) * sizeof(WCHAR);
|
||||
UnicodeString.MaximumLength = UnicodeString.Length + sizeof(WCHAR);
|
||||
if (UnicodeString.Length > 0)
|
||||
{
|
||||
DPRINT("UnicodeString.Buffer \'%S\'\n", UnicodeString.Buffer);
|
||||
AnsiString.Length = 0;
|
||||
AnsiString.MaximumLength = Length + 1 - (AnsiString.Buffer - EnvPtr);
|
||||
|
||||
RtlUnicodeStringToAnsiString (&AnsiString,
|
||||
&UnicodeString,
|
||||
FALSE);
|
||||
|
||||
DPRINT("AnsiString.Buffer \'%s\'\n", AnsiString.Buffer);
|
||||
|
||||
AnsiString.Buffer += (AnsiString.Length + 1);
|
||||
UnicodeString.Buffer += ((UnicodeString.Length / sizeof(WCHAR)) + 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue