pass the buffer size to GetEnvironmentVariable() in characters, not bytes!
authorThomas Bluemel <thomas@reactsoft.com>
Wed, 21 Sep 2005 17:23:27 +0000 (17:23 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Wed, 21 Sep 2005 17:23:27 +0000 (17:23 +0000)
svn path=/trunk/; revision=17968

reactos/subsys/system/cmd/cmd.c
reactos/subsys/system/cmd/if.c
reactos/subsys/system/cmd/where.c

index 1c6966f..9927f1c 100644 (file)
@@ -1552,7 +1552,7 @@ Initialize (int argc, TCHAR* argv[])
           for you can change the EnvirommentVariable for prompt before cmd start
           this patch are not 100% right, if it does not exists a PROMPT value cmd should use
           $P$G as defualt not set EnvirommentVariable PROMPT to $P$G if it does not exists */
-       if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, 2 * sizeof(TCHAR)) == 0)
+       if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, sizeof(lpBuffer) / sizeof(lpBuffer[0])) == 0)
            SetEnvironmentVariable (_T("PROMPT"), _T("$P$G"));
 
 
index ad41639..b040d1c 100644 (file)
@@ -131,7 +131,7 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
                if (*pp)
                {
                        *pp++ = _T('\0');
-                       ValueSize = GetEnvironmentVariable(param, Value, sizeof Value);
+                       ValueSize = GetEnvironmentVariable(param, Value, sizeof(Value) / sizeof(Value[0]));
                        x_flag ^= (0 == ValueSize)
                                        ? 0
                                        : X_EXEC;
index 5557340..3136f46 100644 (file)
@@ -157,7 +157,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
        if (dwBuffer > ENV_BUFFER_SIZE)
        {
                pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
-               GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer * sizeof (TCHAR));
+               GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer);
        }
 
 
@@ -222,7 +222,7 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
        if (dwBuffer > ENV_BUFFER_SIZE)
        {
                pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
-               GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, dwBuffer * sizeof (TCHAR));
+               GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, dwBuffer);
        }
        else if (0 == dwBuffer)
        {