[PATCH v3 0/4] MR11710: msvcrt: Don't inherit std fd attributes.
-- v3: msvcrt: Also inherit WX_ATEOF and WX_READNL attributes. msvcrt: Don't update system std handles in msvcrt_init_io(). msvcrt: Initialize std handles in a loop in msvcrt_init_io(). msvcrt: Don't inherit std fd attributes. https://gitlab.winehq.org/wine/wine/-/merge_requests/11710
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/msvcrt/file.c | 2 +- dlls/msvcrt/tests/file.c | 138 ++++++++++++++++++++++++++++++--------- 2 files changed, 108 insertions(+), 32 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 71972540c13..f0e3c631e3c 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -743,7 +743,7 @@ void msvcrt_init_io(void) { fdinfo = get_ioinfo_alloc_fd(i); if(fdinfo != &MSVCRT___badioinfo) - msvcrt_set_fd(fdinfo, *handle_ptr, *wxflag_ptr); + msvcrt_set_fd(fdinfo, *handle_ptr, *wxflag_ptr | (i < 3 ? WX_TEXT : 0)); release_ioinfo(fdinfo); } diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 4942780d425..579bfd87808 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1635,29 +1635,56 @@ static void test_file_write_read( void ) static void test_file_inherit_child(const char* fd_s, const char *handle_str) { - HANDLE handle_value; + HANDLE handle_value = (HANDLE)0x1, handle; int fd = atoi(fd_s); HANDLE *handle_ptr; unsigned int count; char buffer[32]; STARTUPINFOA si; - int ret; + int expected; + int ret, pos; + BYTE *wxflags; + ioinfo *info; GetStartupInfoA(&si); count = *(unsigned *)si.lpReserved2; + wxflags = (BYTE *)si.lpReserved2 + sizeof(unsigned); if (handle_str) { - ok(count == 3, "Got unexpected count %u.\n", count); + ok(count >= 3, "Got unexpected count %u.\n", count); sscanf(handle_str, "%p", &handle_value); handle_ptr = (HANDLE *)(si.lpReserved2 + sizeof(unsigned) + count); - ok(handle_value == handle_ptr[1], "Got unexpected handle %p.\n", handle_ptr[1]); + ok(handle_value == handle_ptr[fd], "Got unexpected handle %p.\n", handle_ptr[1]); + if (handle_value && handle_value != (HANDLE)0xdeadbeef && handle_value != INVALID_HANDLE_VALUE) + { + handle = (HANDLE)_get_osfhandle(fd); + ok(handle == handle_value, "got %p, %p.\n", handle, handle_value); + } } + if (si.cbReserved2 < sizeof(unsigned) + sizeof(BYTE) * count + sizeof(HANDLE) * count) + count = 0; + if (count > fd) + { + info = &__pioinfo[fd / MSVCRT_FD_BLOCK_SIZE][fd % MSVCRT_FD_BLOCK_SIZE]; + expected = wxflags[fd]; + if (fd < 3) + expected |= WX_TEXT; + if (!handle_value || handle_value == INVALID_HANDLE_VALUE || handle_value == (HANDLE)0xdeadbeef) + expected &= ~WX_APPEND; + ok(info->wxflag == expected, "got %#x, expected %#x, fd %d, handle %p.\n", info->wxflag, expected, fd, handle_value); + } + + pos = lseek(fd, 0, SEEK_CUR); ret = write(fd, "Success", 8); ok( ret == 8, "Couldn't write in child process on %d (%s)\n", fd, strerror(errno)); - lseek(fd, 0, SEEK_SET); - ok(read(fd, buffer, sizeof (buffer)) == 8, "Couldn't read back the data\n"); - ok(memcmp(buffer, "Success", 8) == 0, "Couldn't read back the data\n"); + + lseek(fd, pos, SEEK_SET); + ret = read(fd, buffer, sizeof (buffer)); + if (ret == -1 && errno == EBADF) + return; + ok(ret == 8, "Couldn't read back the data, got %d, errno %d\n", ret, errno); + ok(memcmp(buffer, "Success", 8) == 0, "Read back data mismatch\n"); } static void test_file_inherit_child_no(const char* fd_s) @@ -1670,7 +1697,7 @@ static void test_file_inherit_child_no(const char* fd_s) "Wrong write result in child process on %d (%s)\n", fd, strerror(errno)); } -static void create_io_inherit_block( STARTUPINFOA *startup, unsigned int count, const HANDLE *handles ) +static void create_io_inherit_block( STARTUPINFOA *startup, unsigned int count, const HANDLE *handles, BYTE wxflag ) { static BYTE block[1024]; BYTE *wxflag_ptr; @@ -1685,7 +1712,7 @@ static void create_io_inherit_block( STARTUPINFOA *startup, unsigned int count, *(unsigned*)block = count; for (i = 0; i < count; i++) { - wxflag_ptr[i] = 0x81; + wxflag_ptr[i] = wxflag; handle_ptr[i] = handles[i]; } } @@ -1701,7 +1728,7 @@ static const char *read_file( HANDLE file ) } static void test_stdout_handle( STARTUPINFOA *startup, char *cmdline, HANDLE hstdout, BOOL expect_stdout, - const char *descr ) + const char *descr, BOOL set_invalid_stdout ) { const char *data; HANDLE hErrorFile; @@ -1717,7 +1744,7 @@ static void test_stdout_handle( STARTUPINFOA *startup, char *cmdline, HANDLE hst FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); startup->dwFlags = STARTF_USESTDHANDLES; startup->hStdInput = GetStdHandle( STD_INPUT_HANDLE ); - startup->hStdOutput = hErrorFile; + startup->hStdOutput = set_invalid_stdout ? INVALID_HANDLE_VALUE : hErrorFile; startup->hStdError = GetStdHandle( STD_ERROR_HANDLE ); CreateProcessA( NULL, cmdline, NULL, NULL, TRUE, @@ -1734,7 +1761,7 @@ static void test_stdout_handle( STARTUPINFOA *startup, char *cmdline, HANDLE hst { data = read_file( hstdout ); if (expect_stdout) - ok( !strcmp( data, "Success" ), "%s: Wrong stdout data (%s)\n", descr, data ); + ok( !strcmp( data, "Success" ), "%s: Wrong stdout data (%s)\n", descr, debugstr_a(data) ); else ok( strcmp( data, "Success" ), "%s: Stdout file shouldn't contain data\n", descr ); } @@ -1763,10 +1790,11 @@ static void test_file_inherit( const char* selfname ) char cmdline[MAX_PATH]; STARTUPINFOA startup; SECURITY_ATTRIBUTES sa; - HANDLE handles[3]; + HANDLE handles[4]; HANDLE thread_handle; int pipefds[2]; intptr_t ret; + int mode, i; fd = open ("fdopen.tst", O_CREAT | O_RDWR | O_BINARY, _S_IREAD |_S_IWRITE); ok(fd != -1, "Couldn't create test file\n"); @@ -1782,6 +1810,19 @@ static void test_file_inherit( const char* selfname ) ok(read(fd, buffer, sizeof (buffer)) == 8 && memcmp(buffer, "Success", 8) == 0, "Couldn't read back the data\n"); close (fd); ok(unlink("fdopen.tst") == 0, "Couldn't unlink\n"); + + /* For std handle binary mode on it is not going to be inherited and set to default text mode instead. */ + mode = _setmode(1, O_BINARY); + ok(mode != -1, "got %#x.\n", mode); + arg_v[0] = get_base_name(selfname); + arg_v[1] = "file"; + arg_v[2] = "inherit"; + arg_v[3] = buffer; sprintf(buffer, "%d", 1); + arg_v[4] = 0; + ret = _spawnvp(_P_WAIT, selfname, arg_v); + mode = _setmode(1, mode); + ok(ret == 0, "_spawnvp returned %Id, errno %d\n", ret, errno); + ok(mode == O_BINARY, "got %#x.\n", mode); fd = open ("fdopen.tst", O_CREAT | O_RDWR | O_BINARY | O_NOINHERIT, _S_IREAD |_S_IWRITE); ok(fd != -1, "Couldn't create test file\n"); @@ -1829,70 +1870,105 @@ static void test_file_inherit( const char* selfname ) /* init an empty Reserved2, which should not be recognized as inherit-block */ ZeroMemory(&startup, sizeof(startup)); startup.cb = sizeof(startup); - create_io_inherit_block( &startup, 0, NULL ); - test_stdout_handle( &startup, cmdline, 0, FALSE, "empty block" ); + create_io_inherit_block( &startup, 0, NULL, WX_OPEN ); + test_stdout_handle( &startup, cmdline, 0, FALSE, "empty block", FALSE ); /* test with valid inheritblock */ handles[0] = GetStdHandle( STD_INPUT_HANDLE ); handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); handles[2] = GetStdHandle( STD_ERROR_HANDLE ); - create_io_inherit_block( &startup, 3, handles ); - test_stdout_handle( &startup, cmdline, handles[1], TRUE, "valid block" ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); + test_stdout_handle( &startup, cmdline, handles[1], TRUE, "valid block", FALSE ); CloseHandle( handles[1] ); DeleteFileA("fdopen.tst"); /* test inherit block starting with unsigned zero */ handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); - create_io_inherit_block( &startup, 3, handles ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); *(unsigned int *)startup.lpReserved2 = 0; - test_stdout_handle( &startup, cmdline, handles[1], FALSE, "zero count block" ); + test_stdout_handle( &startup, cmdline, handles[1], FALSE, "zero count block", FALSE ); CloseHandle( handles[1] ); DeleteFileA("fdopen.tst"); /* test inherit block with smaller size */ handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); - create_io_inherit_block( &startup, 3, handles ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); startup.cbReserved2 -= 3; - test_stdout_handle( &startup, cmdline, handles[1], TRUE, "small size block" ); + test_stdout_handle( &startup, cmdline, handles[1], TRUE, "small size block", FALSE ); CloseHandle( handles[1] ); DeleteFileA("fdopen.tst"); /* test inherit block with even smaller size */ handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); - create_io_inherit_block( &startup, 3, handles ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); startup.cbReserved2 = sizeof(unsigned int) + sizeof(HANDLE) + sizeof(char); - test_stdout_handle( &startup, cmdline, handles[1], FALSE, "smaller size block" ); + test_stdout_handle( &startup, cmdline, handles[1], FALSE, "smaller size block", FALSE ); CloseHandle( handles[1] ); DeleteFileA("fdopen.tst"); /* test inherit block with larger size */ handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); - create_io_inherit_block( &startup, 3, handles ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); startup.cbReserved2 += 7; - test_stdout_handle( &startup, cmdline, handles[1], TRUE, "large size block" ); + test_stdout_handle( &startup, cmdline, handles[1], TRUE, "large size block", FALSE ); CloseHandle( handles[1] ); DeleteFileA("fdopen.tst"); /* test inherit block with invalid handle */ handles[1] = INVALID_HANDLE_VALUE; - create_io_inherit_block( &startup, 3, handles ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); sprintf(cmdline, "%s file inherit 1 %p", selfname, handles[1]); - test_stdout_handle( &startup, cmdline, NULL, FALSE, "INVALID_HANDLE_VALUE stdout handle" ); + test_stdout_handle( &startup, cmdline, NULL, FALSE, "INVALID_HANDLE_VALUE stdout handle", FALSE ); handles[1] = NULL; - create_io_inherit_block( &startup, 3, handles ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); sprintf(cmdline, "%s file inherit 1 %p", selfname, handles[1]); - test_stdout_handle( &startup, cmdline, NULL, FALSE, "NULL stdout handle" ); + test_stdout_handle( &startup, cmdline, NULL, FALSE, "NULL stdout handle", FALSE ); handles[1] = (void *)0xdeadbeef; - create_io_inherit_block( &startup, 3, handles ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); sprintf(cmdline, "%s file inherit 1 %p", selfname, handles[1]); - test_stdout_handle( &startup, cmdline, NULL, FALSE, "invalid stdout handle" ); + test_stdout_handle( &startup, cmdline, NULL, FALSE, "invalid stdout handle", FALSE ); + + /* std handle doesn't respect binary mode from inherited block, while non-std handle does. */ + for (i = 1; i < 8; ++i) + { + mode = WX_OPEN | (1 << i); + if (mode & (WX_ATEOF | WX_READNL)) + continue; + winetest_push_context("wxflags %#x", mode); + handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); + create_io_inherit_block( &startup, 3, handles, mode ); + sprintf(cmdline, "%s file inherit 1 %p", selfname, handles[1]); + test_stdout_handle( &startup, cmdline, handles[1], TRUE, "stdout mode", FALSE ); + CloseHandle( handles[1] ); + DeleteFileA("fdopen.tst"); + winetest_pop_context(); + } + handles[3] = CreateFileA( "fdopen2.tst", GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); + handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); + create_io_inherit_block( &startup, 4, handles, WX_OPEN ); + sprintf(cmdline, "%s file inherit 3 %p", selfname, handles[3]); + test_stdout_handle( &startup, cmdline, handles[3], TRUE, "non-std handle", FALSE ); + CloseHandle( handles[1] ); + DeleteFileA("fdopen.tst"); + DeleteFileA("fdopen2.tst"); + + handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); + create_io_inherit_block( &startup, 3, handles, WX_OPEN ); + sprintf(cmdline, "%s file inherit 1 %p", selfname, handles[1]); + test_stdout_handle( &startup, cmdline, handles[1], TRUE, "valid CRT, invalid kernelbase", TRUE ); + CloseHandle( handles[1] ); + DeleteFileA("fdopen.tst"); } static void test_invalid_stdin_child( void ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11710
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/msvcrt/file.c | 78 +++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 53 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index f0e3c631e3c..89b55d1d6c5 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -751,62 +751,34 @@ void msvcrt_init_io(void) } } - fdinfo = get_ioinfo_alloc_fd(STDIN_FILENO); - if (!(fdinfo->wxflag & WX_OPEN) || fdinfo->handle == INVALID_HANDLE_VALUE) { - HANDLE h = GetStdHandle(STD_INPUT_HANDLE); - DWORD flags = WX_OPEN | WX_TEXT; - DWORD type = GetFileType(h); - - if (type == FILE_TYPE_UNKNOWN) { - h = MSVCRT_NO_CONSOLE; - flags |= WX_TTY; - } else if ((type & 0xf) == FILE_TYPE_CHAR) { - flags |= WX_TTY; - } else if ((type & 0xf) == FILE_TYPE_PIPE) { - flags |= WX_PIPE; - } - - msvcrt_set_fd(fdinfo, h, flags); - } - release_ioinfo(fdinfo); - - fdinfo = get_ioinfo_alloc_fd(STDOUT_FILENO); - if (!(fdinfo->wxflag & WX_OPEN) || fdinfo->handle == INVALID_HANDLE_VALUE) { - HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD flags = WX_OPEN | WX_TEXT; - DWORD type = GetFileType(h); - - if (type == FILE_TYPE_UNKNOWN) { - h = MSVCRT_NO_CONSOLE; - flags |= WX_TTY; - } else if ((type & 0xf) == FILE_TYPE_CHAR) { - flags |= WX_TTY; - } else if ((type & 0xf) == FILE_TYPE_PIPE) { - flags |= WX_PIPE; - } - - msvcrt_set_fd(fdinfo, h, flags); - } - release_ioinfo(fdinfo); + for (i = 0; i < 3; ++i) + { + static const DWORD std_handle[3] = { STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE }; + DWORD flags = WX_OPEN | WX_TEXT, type; + HANDLE h; - fdinfo = get_ioinfo_alloc_fd(STDERR_FILENO); - if (!(fdinfo->wxflag & WX_OPEN) || fdinfo->handle == INVALID_HANDLE_VALUE) { - HANDLE h = GetStdHandle(STD_ERROR_HANDLE); - DWORD flags = WX_OPEN | WX_TEXT; - DWORD type = GetFileType(h); - - if (type == FILE_TYPE_UNKNOWN) { - h = MSVCRT_NO_CONSOLE; - flags |= WX_TTY; - } else if ((type & 0xf) == FILE_TYPE_CHAR) { - flags |= WX_TTY; - } else if ((type & 0xf) == FILE_TYPE_PIPE) { - flags |= WX_PIPE; + fdinfo = get_ioinfo_alloc_fd(i); + if (!(fdinfo->wxflag & WX_OPEN) || fdinfo->handle == INVALID_HANDLE_VALUE) + { + h = GetStdHandle(std_handle[i]); + type = GetFileType(h); + if (type == FILE_TYPE_UNKNOWN) + { + h = MSVCRT_NO_CONSOLE; + flags |= WX_TTY; + } + else if ((type & 0xf) == FILE_TYPE_CHAR) + { + flags |= WX_TTY; + } + else if ((type & 0xf) == FILE_TYPE_PIPE) + { + flags |= WX_PIPE; + } + msvcrt_set_fd(fdinfo, h, flags); } - - msvcrt_set_fd(fdinfo, h, flags); + release_ioinfo(fdinfo); } - release_ioinfo(fdinfo); TRACE(":handles (%p)(%p)(%p)\n", get_ioinfo_nolock(STDIN_FILENO)->handle, get_ioinfo_nolock(STDOUT_FILENO)->handle, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11710
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/msvcrt/file.c | 10 +++++++--- dlls/msvcrt/tests/file.c | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 89b55d1d6c5..636e88d9f2f 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -574,7 +574,7 @@ static void msvcrt_free_fd(int fd) release_ioinfo(fdinfo); } -static void msvcrt_set_fd(ioinfo *fdinfo, HANDLE hand, int flag) +static void msvcrt_set_fdinfo(ioinfo *fdinfo, HANDLE hand, int flag) { fdinfo->handle = hand; fdinfo->wxflag = WX_OPEN | (flag & (WX_DONTINHERIT | WX_APPEND | WX_TEXT | WX_PIPE | WX_TTY)); @@ -583,7 +583,11 @@ static void msvcrt_set_fd(ioinfo *fdinfo, HANDLE hand, int flag) fdinfo->lookahead[2] = '\n'; ioinfo_set_unicode(fdinfo, FALSE); ioinfo_set_textmode(fdinfo, TEXTMODE_ANSI); +} +static void msvcrt_set_fd(ioinfo *fdinfo, HANDLE hand, int flag) +{ + msvcrt_set_fdinfo(fdinfo, hand, flag); if (hand != MSVCRT_NO_CONSOLE) { switch (fdinfo-MSVCRT___pioinfo[0]) @@ -743,7 +747,7 @@ void msvcrt_init_io(void) { fdinfo = get_ioinfo_alloc_fd(i); if(fdinfo != &MSVCRT___badioinfo) - msvcrt_set_fd(fdinfo, *handle_ptr, *wxflag_ptr | (i < 3 ? WX_TEXT : 0)); + msvcrt_set_fdinfo(fdinfo, *handle_ptr, *wxflag_ptr | (i < 3 ? WX_TEXT : 0)); release_ioinfo(fdinfo); } @@ -775,7 +779,7 @@ void msvcrt_init_io(void) { flags |= WX_PIPE; } - msvcrt_set_fd(fdinfo, h, flags); + msvcrt_set_fdinfo(fdinfo, h, flags); } release_ioinfo(fdinfo); } diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 579bfd87808..fc6db0ef07c 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1659,6 +1659,11 @@ static void test_file_inherit_child(const char* fd_s, const char *handle_str) { handle = (HANDLE)_get_osfhandle(fd); ok(handle == handle_value, "got %p, %p.\n", handle, handle_value); + if (fd == 1) + { + handle = GetStdHandle(STD_OUTPUT_HANDLE); + ok(handle != handle_value, "got equal handles %p.\n", handle); + } } } if (si.cbReserved2 < sizeof(unsigned) + sizeof(BYTE) * count + sizeof(HANDLE) * count) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11710
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/msvcrt/file.c | 3 ++- dlls/msvcrt/tests/file.c | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 636e88d9f2f..841894fb9da 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -577,7 +577,7 @@ static void msvcrt_free_fd(int fd) static void msvcrt_set_fdinfo(ioinfo *fdinfo, HANDLE hand, int flag) { fdinfo->handle = hand; - fdinfo->wxflag = WX_OPEN | (flag & (WX_DONTINHERIT | WX_APPEND | WX_TEXT | WX_PIPE | WX_TTY)); + fdinfo->wxflag = WX_OPEN | flag; fdinfo->lookahead[0] = '\n'; fdinfo->lookahead[1] = '\n'; fdinfo->lookahead[2] = '\n'; @@ -587,6 +587,7 @@ static void msvcrt_set_fdinfo(ioinfo *fdinfo, HANDLE hand, int flag) static void msvcrt_set_fd(ioinfo *fdinfo, HANDLE hand, int flag) { + flag &= ~(WX_ATEOF | WX_READNL); msvcrt_set_fdinfo(fdinfo, hand, flag); if (hand != MSVCRT_NO_CONSOLE) { diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index fc6db0ef07c..e65c910271b 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1944,8 +1944,6 @@ static void test_file_inherit( const char* selfname ) for (i = 1; i < 8; ++i) { mode = WX_OPEN | (1 << i); - if (mode & (WX_ATEOF | WX_READNL)) - continue; winetest_push_context("wxflags %#x", mode); handles[1] = CreateFileA( "fdopen.tst", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11710
v2: - refactor test to check wxflags directly in ioinfo structure (that is only problematic in ucrtbase, with msvcrt test it is easy); - test all the flags inheritence; - update implementation accordingly; - still refactor importing std handles in a separate while now it is not rearranged with setting handles from lpRserved and thus is not connected to other patches. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11710#note_149448
v3: - rename the first patch to reflect what it is doing now. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11710#note_149449
participants (2)
-
Paul Gofman -
Paul Gofman (@gofman)