From: Stefan Metzmacher Date: Wed, 3 Jul 2024 08:58:33 +0000 (+0200) Subject: smbd: correctly restore ENOENT if fstatfs() modifies it X-Git-Tag: tdb-1.4.11~196 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2aca5cfbfa45d2fcf00688388688812445123f3f;p=thirdparty%2Fsamba.git smbd: correctly restore ENOENT if fstatfs() modifies it Review with: git show -U5 Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Wed Jul 3 11:41:12 UTC 2024 on atb-devel-224 --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 0c101c19b46..7999b3f082e 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1190,10 +1190,8 @@ static NTSTATUS reopen_from_fsp(struct files_struct *dirfsp, struct statfs sbuf = {}; int ret = fstatfs(old_fd, &sbuf); if (ret == -1) { - int saved_errno = errno; DBG_ERR("fstatfs failed: %s\n", strerror(errno)); - errno = saved_errno; } else if (sbuf.f_type == AUTOFS_SUPER_MAGIC) { /* * When reopening an as-yet @@ -1203,6 +1201,8 @@ static NTSTATUS reopen_from_fsp(struct files_struct *dirfsp, */ goto namebased_open; } + /* restore ENOENT if changed in the meantime */ + errno = ENOENT; } #endif status = map_nt_error_from_unix(errno);