[2/2] msvcrt: msvcrt: check nd passed to _dup2 is positive

Jeff Zaroyko jeffzaroyko at gmail.com
Mon Jan 11 21:25:56 CST 2010


Fixes bug 21289.
-------------- next part --------------
From 29079c953cbca8a290b650126aaccbff8caed9be Mon Sep 17 00:00:00 2001
From: Jeff Zaroyko <jeffz at jeffz.name>
Date: Tue, 12 Jan 2010 14:14:33 +1100
Subject: msvcrt: check nd passed to _dup2 is positive

---
 dlls/msvcrt/file.c       |    2 +-
 dlls/msvcrt/tests/file.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index cbaa04e..df42d47 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -705,7 +705,7 @@ int CDECL MSVCRT__dup2(int od, int nd)
 
   TRACE("(od=%d, nd=%d)\n", od, nd);
   LOCK_FILES();
-  if (nd < MSVCRT_MAX_FILES && msvcrt_is_valid_fd(od))
+  if (nd < MSVCRT_MAX_FILES && nd >= 0 && msvcrt_is_valid_fd(od))
   {
     HANDLE handle;
 
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index 27d64bd..042a82e 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -1363,7 +1363,7 @@ static void test_unlink(void)
 
 void test_dup2(void)
 {
-    todo_wine ok(-1 == _dup2(0, -1), "expected _dup2 to fail when second arg is negative\n" );
+    ok(-1 == _dup2(0, -1), "expected _dup2 to fail when second arg is negative\n" );
 }
 
 START_TEST(file)
-- 
1.5.4.3


More information about the wine-patches mailing list