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

This commit is contained in:
Alexandre Julliard 2007-01-18 12:18:51 +01:00
parent 027491f6af
commit 3410354d61
5 changed files with 10 additions and 3 deletions

View File

@ -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 );

View File

@ -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 */

View File

@ -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 );
}
}

View File

@ -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

View File

@ -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 );
}