Commit 53bc6c7a authored by Michel Zou's avatar Michel Zou Committed by Alexandre Julliard

msvcrt: Fix errno set on dup from read-only file.

parent 7ca1eff8
......@@ -1244,6 +1244,7 @@ int CDECL _dup2(int od, int nd)
if (info_nd == &MSVCRT___badioinfo)
{
*_errno() = EBADF;
ret = -1;
}
else if (info_od->wxflag & WX_OPEN)
......
......@@ -267,6 +267,12 @@ static void test_readmode( BOOL ascii_mode )
close (fd);
fd = open ("fdopen.tst", O_RDONLY, _S_IREAD |_S_IWRITE);
errno = 0xdeadbeef;
ok(dup2(fd, -1) == -1, "dup2(fd, -1) succeeded\n");
ok(errno == EBADF, "errno = %d\n", errno);
close (fd);
if (ascii_mode) {
/* Open file in ascii mode */
fd = open ("fdopen.tst", O_RDONLY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment