Module: wine Branch: master Commit: 3410354d61c3c2c6f9963dcec132d6560b1504d5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3410354d61c3c2c6f9963dcec1...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Jan 18 12:18:51 2007 +0100
ntdll: Fix NtDuplicateObject to only close the file descriptor if it's in the same process.
---
dlls/ntdll/om.c | 7 +++++-- include/wine/server_protocol.h | 3 ++- server/handle.c | 1 + server/protocol.def | 1 + server/trace.c | 1 + 5 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/om.c b/dlls/ntdll/om.c index 56612dc..cac8713 100644 --- a/dlls/ntdll/om.c +++ b/dlls/ntdll/om.c @@ -314,8 +314,11 @@ NTSTATUS WINAPI NtDuplicateObject( HANDL 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 ); diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index ca98f28..6f7a652 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -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 */ diff --git a/server/handle.c b/server/handle.c index 887fbca..f8f007d 100644 --- a/server/handle.c +++ b/server/handle.c @@ -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 ); } } diff --git a/server/protocol.def b/server/protocol.def index 343fbbb..535ef12 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -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 diff --git a/server/trace.c b/server/trace.c index 6766faf..4e63093 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1025,6 +1025,7 @@ static void dump_dup_handle_request( con 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 ); }