Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53950
-- v4: msvcrt: Fix errno set on dup from read-only file.
From: Michel Zou xantares09@hotmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53950 --- dlls/msvcrt/file.c | 1 + dlls/msvcrt/tests/file.c | 6 ++++++ 2 files changed, 7 insertions(+)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 4a8c3510bd7..e72784eef41 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -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) diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index de21d11d0b9..3f57b3f871f 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -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);
On Mon Nov 28 19:44:16 2022 +0000, xantares wrote:
changed this line in [version 4 of the diff](/wine/wine/-/merge_requests/1553/diffs?diff_id=21377&start_sha=9976e64ff8d0805e259a25b7f6c5613e92d260b3#1a28d67ae45bfb1e18198f92ca618b484c4e5a63_272_272)
ok
@piotr anything else I should do ?
This merge request was approved by Piotr Caban.
On Wed Nov 30 10:10:07 2022 +0000, xantares wrote:
@piotr anything else I should do ?
No, I just had to run some more tests to check where the errno should be set.