[PATCH 1/6] msvcrt: Use LOCK_ENV locking in _chdrive and do validatation of input argument.

Kai Tietz ktietz70 at googlemail.com
Thu Aug 8 11:36:19 CDT 2013


Due line wrap of this gmail-thng, I attach the changes.

Sorry,
Kai
-------------- next part --------------
From 1fd675436864a11c01995c1668b625bc80037f76 Mon Sep 17 00:00:00 2001
From: Kai Tietz <ktietz70 at googlemail.com>
Date: Thu, 29 Dec 2011 14:44:40 +0100
Subject: [PATCH 2/7] msvcrt: Use LOCK_ENV locking in _chdrive and do
 validatation of input argument.

---
 dlls/msvcrt/dir.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c
index 44802b3..3b9e3c7 100644
--- a/dlls/msvcrt/dir.c
+++ b/dlls/msvcrt/dir.c
@@ -365,14 +365,25 @@ int CDECL MSVCRT__chdrive(int newdrive)
 {
   WCHAR buffer[] = {'A', ':', 0};
 
+  if (newdrive < 1 || newdrive > 31)
+  {
+    *MSVCRT___doserrno () = ERROR_INVALID_DRIVE;
+    *MSVCRT__errno () = MSVCRT_EACCES;
+    return -1;
+  }
   buffer[0] += newdrive - 1;
-  if (!SetCurrentDirectoryW( buffer ))
+
+  _lock (_ENV_LOCK);
+
+  if (!SetCurrentDirectoryW (buffer))
   {
-    msvcrt_set_errno(GetLastError());
-    if (newdrive <= 0)
-      *MSVCRT__errno() = MSVCRT_EACCES;
+    msvcrt_set_errno (GetLastError ());
+    _unlock (_ENV_LOCK);
     return -1;
   }
+
+  _unlock (_ENV_LOCK);
+
   return 0;
 }
 
-- 
1.7.9


More information about the wine-patches mailing list