mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 06:02:56 +00:00
[KERNEL32]: In failure cases we should return one more byte for ANSI_NULL as well. Also fix another length check.
svn path=/trunk/; revision=54279
This commit is contained in:
parent
5ef1d7f8d2
commit
5671dd839b
1 changed files with 6 additions and 8 deletions
|
@ -457,8 +457,8 @@ ExpandEnvironmentStringsA(IN LPCSTR lpSrc,
|
||||||
Status = RtlExpandEnvironmentStrings_U(NULL, &SourceU, &DestU, &Length);
|
Status = RtlExpandEnvironmentStrings_U(NULL, &SourceU, &DestU, &Length);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Get the ASCII length of the variable */
|
/* Get the ASCII length of the variable, add a byte for NULL */
|
||||||
Result = RtlUnicodeStringToAnsiSize(&DestU);
|
Result = RtlUnicodeStringToAnsiSize(&DestU) + sizeof(ANSI_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -475,16 +475,14 @@ ExpandEnvironmentStringsA(IN LPCSTR lpSrc,
|
||||||
|
|
||||||
/* Check the size */
|
/* Check the size */
|
||||||
Result = RtlUnicodeStringToAnsiSize(&DestU);
|
Result = RtlUnicodeStringToAnsiSize(&DestU);
|
||||||
if (Result <= nSize)
|
if (Result <= UniSize)
|
||||||
{
|
{
|
||||||
/* Convert the string */
|
/* Convert the string */
|
||||||
RtlInitEmptyAnsiString(&Dest, lpDst, UniSize);
|
RtlInitEmptyAnsiString(&Dest, lpDst, UniSize);
|
||||||
Status = RtlUnicodeStringToAnsiString(&Dest, &DestU, FALSE);
|
Status = RtlUnicodeStringToAnsiString(&Dest, &DestU, FALSE);
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
/* Write a NULL-char in case of failure only */
|
||||||
/* Clear the destination */
|
if (!NT_SUCCESS(Status)) *lpDst = ANSI_NULL;
|
||||||
*lpDst = ANSI_NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Quickie:
|
Quickie:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue