msvcrt: Ignore inherited FDs with invalid handles in msvcrt_init_io().
The process std handles should be preserved in this case. Fixes error on startup in "Re:ZERO -Starting Life in Another World- The Prophecy of the Throne" launcher. Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5007f6fa35
commit
611742d31f
|
@ -586,7 +586,7 @@ void msvcrt_init_io(void)
|
|||
count = min(count, MSVCRT_MAX_FILES);
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if ((*wxflag_ptr & WX_OPEN) && *handle_ptr != INVALID_HANDLE_VALUE)
|
||||
if ((*wxflag_ptr & WX_OPEN) && GetFileType(*handle_ptr) != FILE_TYPE_UNKNOWN)
|
||||
{
|
||||
fdinfo = get_ioinfo_alloc_fd(i);
|
||||
if(fdinfo != &MSVCRT___badioinfo)
|
||||
|
|
|
@ -1454,13 +1454,27 @@ static void test_file_write_read( void )
|
|||
free(tempf);
|
||||
}
|
||||
|
||||
static void test_file_inherit_child(const char* fd_s)
|
||||
static void test_file_inherit_child(const char* fd_s, const char *handle_str)
|
||||
{
|
||||
HANDLE handle_value;
|
||||
int fd = atoi(fd_s);
|
||||
HANDLE *handle_ptr;
|
||||
unsigned int count;
|
||||
char buffer[32];
|
||||
STARTUPINFOA si;
|
||||
int ret;
|
||||
|
||||
ret =write(fd, "Success", 8);
|
||||
GetStartupInfoA(&si);
|
||||
count = *(unsigned *)si.lpReserved2;
|
||||
if (handle_str)
|
||||
{
|
||||
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]);
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -1643,6 +1657,22 @@ static void test_file_inherit( const char* selfname )
|
|||
test_stdout_handle( &startup, cmdline, handles[1], TRUE, "large size block" );
|
||||
CloseHandle( handles[1] );
|
||||
DeleteFileA("fdopen.tst");
|
||||
|
||||
/* test inherit block with invalid handle */
|
||||
handles[1] = INVALID_HANDLE_VALUE;
|
||||
create_io_inherit_block( &startup, 3, handles );
|
||||
sprintf(cmdline, "%s file inherit 1 %p", selfname, handles[1]);
|
||||
test_stdout_handle( &startup, cmdline, NULL, FALSE, "INVALID_HANDLE_VALUE stdout handle" );
|
||||
|
||||
handles[1] = NULL;
|
||||
create_io_inherit_block( &startup, 3, handles );
|
||||
sprintf(cmdline, "%s file inherit 1 %p", selfname, handles[1]);
|
||||
test_stdout_handle( &startup, cmdline, NULL, FALSE, "NULL stdout handle" );
|
||||
|
||||
handles[1] = (void *)0xdeadbeef;
|
||||
create_io_inherit_block( &startup, 3, handles );
|
||||
sprintf(cmdline, "%s file inherit 1 %p", selfname, handles[1]);
|
||||
test_stdout_handle( &startup, cmdline, NULL, FALSE, "invalid stdout handle" );
|
||||
}
|
||||
|
||||
static void test_invalid_stdin_child( void )
|
||||
|
@ -2714,7 +2744,7 @@ START_TEST(file)
|
|||
if (arg_c >= 3)
|
||||
{
|
||||
if (strcmp(arg_v[2], "inherit") == 0)
|
||||
test_file_inherit_child(arg_v[3]);
|
||||
test_file_inherit_child(arg_v[3], arg_c > 4 ? arg_v[4] : NULL);
|
||||
else if (strcmp(arg_v[2], "inherit_no") == 0)
|
||||
test_file_inherit_child_no(arg_v[3]);
|
||||
else if (strcmp(arg_v[2], "pipes") == 0)
|
||||
|
|
Loading…
Reference in New Issue