Commit 3410354d authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Fix NtDuplicateObject to only close the file descriptor if it's in the same process.

parent 027491f6
......@@ -314,8 +314,11 @@ NTSTATUS WINAPI NtDuplicateObject( HANDLE source_process, HANDLE source,
if (dest) *dest = reply->handle;
if (reply->closed)
{
int fd = server_remove_fd_from_cache( source );
if (fd != -1) close( fd );
if (reply->self)
{
int fd = server_remove_fd_from_cache( source );
if (fd != -1) close( fd );
}
}
else if (options & DUPLICATE_CLOSE_SOURCE)
WARN( "failed to close handle %p in process %p\n", source, source_process );
......
......@@ -740,6 +740,7 @@ struct dup_handle_reply
{
struct reply_header __header;
obj_handle_t handle;
int self;
int closed;
};
#define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
......@@ -4575,6 +4576,6 @@ union generic_reply
struct query_symlink_reply query_symlink_reply;
};
#define SERVER_PROTOCOL_VERSION 270
#define SERVER_PROTOCOL_VERSION 271
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -536,6 +536,7 @@ DECL_HANDLER(dup_handle)
reply->closed = close_handle( src, req->src_handle );
set_error( err );
}
reply->self = (src == current->process);
release_object( src );
}
}
......@@ -635,6 +635,7 @@ typedef union
unsigned int options; /* duplicate options (see below) */
@REPLY
obj_handle_t handle; /* duplicated handle in dst process */
int self; /* is the source the current process? */
int closed; /* whether the source handle has been closed */
@END
#define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
......
......@@ -1025,6 +1025,7 @@ static void dump_dup_handle_request( const struct dup_handle_request *req )
static void dump_dup_handle_reply( const struct dup_handle_reply *req )
{
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " self=%d,", req->self );
fprintf( stderr, " closed=%d", req->closed );
}
......
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