From 34a1b047ce01713d9c3e521177cde3162d9c56c3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 11 Sep 2014 10:03:01 -0700 Subject: [PATCH] s3: smbd - open logic fix. As we atomically create using O_CREAT|O_EXCL, then if new_file_created is true, then file_existed *MUST* have been false (even if the file was previously detected as being there. We use the variable file_existed again in logic below this statement, so we must set file_existed = false, if new_file_created returns are true from open_file(). Based on a fix from Michael Adam. Signed-off-by: Jeremy Allison --- source3/smbd/open.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 6261a449..f077210 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2489,6 +2489,17 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, return fsp_open; } + if (new_file_created) { + /* + * As we atomically create using O_CREAT|O_EXCL, + * then if new_file_created is true, then + * file_existed *MUST* have been false (even + * if the file was previously detected as being + * there). + */ + file_existed = false; + } + if (file_existed && !check_same_dev_ino(&saved_stat, &smb_fname->st)) { /* * The file did exist, but some other (local or NFS) -- 2.1.0.rc2.206.gedb03e5