Author: hbelusca
Date: Sun Oct  7 14:16:13 2012
New Revision: 57514

URL: http://svn.reactos.org/svn/reactos?rev=57514&view=rev
Log:
[NTOSKRNL]
In NtQuerySystemEnvironmentValue :
- Use a fixed-length buffer size for holding a temporary variable.
- Correct the pool TAG.

Modified:
    trunk/reactos/ntoskrnl/ex/sysinfo.c

Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/sysinfo.c?rev=57514&r1=57513&r2=57514&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] Sun Oct  7 14:16:13 2012
@@ -13,6 +13,9 @@
 #include <ntoskrnl.h>
 #define NDEBUG
 #include <debug.h>
+
+/* The maximum size of an environment value (in bytes) */
+#define MAX_ENVVAL_SIZE 1024
 
 FAST_MUTEX ExpEnvironmentLock;
 ERESOURCE ExpFirmwareTableResource;
@@ -246,10 +249,7 @@
 
     /* Copy the name to kernel space if necessary */
     Status = ProbeAndCaptureUnicodeString(&WName, PreviousMode, VariableName);
-    if (!NT_SUCCESS(Status))
-    {
-        return Status;
-    }
+    if (!NT_SUCCESS(Status)) return Status;
 
     /* Convert the name to ANSI and release the captured UNICODE string */
     Status = RtlUnicodeStringToAnsiString(&AName, &WName, TRUE);
@@ -257,7 +257,7 @@
     if (!NT_SUCCESS(Status)) return Status;
 
     /* Allocate a buffer for the ANSI environment variable */
-    AnsiValueBuffer = ExAllocatePoolWithTag(NonPagedPool, ValueBufferLength, 
'pmeT');
+    AnsiValueBuffer = ExAllocatePoolWithTag(NonPagedPool, MAX_ENVVAL_SIZE, 
'rvnE');
     if (AnsiValueBuffer == NULL)
     {
         RtlFreeAnsiString(&AName);
@@ -266,7 +266,7 @@
 
     /* Get the environment variable and free the ANSI name */
     Result = HalGetEnvironmentVariable(AName.Buffer,
-                                       (USHORT)ValueBufferLength,
+                                       MAX_ENVVAL_SIZE,
                                        AnsiValueBuffer);
     RtlFreeAnsiString(&AName);
 
@@ -286,9 +286,7 @@
             Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, FALSE);
 
             if (ReturnLength != NULL)
-            {
                 *ReturnLength = WValue.Length;
-            }
         }
         _SEH2_EXCEPT(ExSystemExceptionFilter())
         {
@@ -302,7 +300,7 @@
     }
 
     /* Free the allocated ANSI value buffer */
-    ExFreePoolWithTag(AnsiValueBuffer, 'pmeT');
+    ExFreePoolWithTag(AnsiValueBuffer, 'rvnE');
 
     return Status;
 }


Reply via email to