mirror of
https://github.com/reactos/reactos.git
synced 2025-06-07 02:10:36 +00:00
[NTOSKRNL]
In NtQuerySystemEnvironmentValue : - Use a fixed-length buffer size for holding a temporary variable. - Correct the pool TAG. svn path=/trunk/; revision=57514
This commit is contained in:
parent
02affbb318
commit
ee0de5e843
1 changed files with 7 additions and 9 deletions
|
@ -14,6 +14,9 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
/* The maximum size of an environment value (in bytes) */
|
||||||
|
#define MAX_ENVVAL_SIZE 1024
|
||||||
|
|
||||||
FAST_MUTEX ExpEnvironmentLock;
|
FAST_MUTEX ExpEnvironmentLock;
|
||||||
ERESOURCE ExpFirmwareTableResource;
|
ERESOURCE ExpFirmwareTableResource;
|
||||||
LIST_ENTRY ExpFirmwareTableProviderListHead;
|
LIST_ENTRY ExpFirmwareTableProviderListHead;
|
||||||
|
@ -246,10 +249,7 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName,
|
||||||
|
|
||||||
/* Copy the name to kernel space if necessary */
|
/* Copy the name to kernel space if necessary */
|
||||||
Status = ProbeAndCaptureUnicodeString(&WName, PreviousMode, VariableName);
|
Status = ProbeAndCaptureUnicodeString(&WName, PreviousMode, VariableName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
{
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert the name to ANSI and release the captured UNICODE string */
|
/* Convert the name to ANSI and release the captured UNICODE string */
|
||||||
Status = RtlUnicodeStringToAnsiString(&AName, &WName, TRUE);
|
Status = RtlUnicodeStringToAnsiString(&AName, &WName, TRUE);
|
||||||
|
@ -257,7 +257,7 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName,
|
||||||
if (!NT_SUCCESS(Status)) return Status;
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
|
|
||||||
/* Allocate a buffer for the ANSI environment variable */
|
/* Allocate a buffer for the ANSI environment variable */
|
||||||
AnsiValueBuffer = ExAllocatePoolWithTag(NonPagedPool, ValueBufferLength, 'pmeT');
|
AnsiValueBuffer = ExAllocatePoolWithTag(NonPagedPool, MAX_ENVVAL_SIZE, 'rvnE');
|
||||||
if (AnsiValueBuffer == NULL)
|
if (AnsiValueBuffer == NULL)
|
||||||
{
|
{
|
||||||
RtlFreeAnsiString(&AName);
|
RtlFreeAnsiString(&AName);
|
||||||
|
@ -266,7 +266,7 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName,
|
||||||
|
|
||||||
/* Get the environment variable and free the ANSI name */
|
/* Get the environment variable and free the ANSI name */
|
||||||
Result = HalGetEnvironmentVariable(AName.Buffer,
|
Result = HalGetEnvironmentVariable(AName.Buffer,
|
||||||
(USHORT)ValueBufferLength,
|
MAX_ENVVAL_SIZE,
|
||||||
AnsiValueBuffer);
|
AnsiValueBuffer);
|
||||||
RtlFreeAnsiString(&AName);
|
RtlFreeAnsiString(&AName);
|
||||||
|
|
||||||
|
@ -286,10 +286,8 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName,
|
||||||
Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, FALSE);
|
Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, FALSE);
|
||||||
|
|
||||||
if (ReturnLength != NULL)
|
if (ReturnLength != NULL)
|
||||||
{
|
|
||||||
*ReturnLength = WValue.Length;
|
*ReturnLength = WValue.Length;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_SEH2_EXCEPT(ExSystemExceptionFilter())
|
_SEH2_EXCEPT(ExSystemExceptionFilter())
|
||||||
{
|
{
|
||||||
Status = _SEH2_GetExceptionCode();
|
Status = _SEH2_GetExceptionCode();
|
||||||
|
@ -302,7 +300,7 @@ NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the allocated ANSI value buffer */
|
/* Free the allocated ANSI value buffer */
|
||||||
ExFreePoolWithTag(AnsiValueBuffer, 'pmeT');
|
ExFreePoolWithTag(AnsiValueBuffer, 'rvnE');
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue