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