From 60287d0ac2920d4baca8522359b1f7d57b258236 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 22 May 2004 03:15:04 +0000 Subject: [PATCH] Make sure we don't truncate the file on open before we have checked the sharing modes (thanks to Dmitry Timoshkov for the test case). --- server/fd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/fd.c b/server/fd.c index 19e2fe9bd18..00b4c51254c 100644 --- a/server/fd.c +++ b/server/fd.c @@ -944,7 +944,7 @@ struct fd *open_fd( struct fd *fd, const char *name, int flags, mode_t *mode, } flags &= ~(O_CREAT | O_EXCL | O_TRUNC); } - if ((fd->unix_fd = open( name, flags, *mode )) == -1) + if ((fd->unix_fd = open( name, flags & ~O_TRUNC, *mode )) == -1) { file_set_error(); release_object( fd ); @@ -990,6 +990,7 @@ struct fd *open_fd( struct fd *fd, const char *name, int flags, mode_t *mode, return NULL; } strcpy( closed_fd->unlink, unlink_name ); + if (flags & O_TRUNC) ftruncate( fd->unix_fd, 0 ); } else {