]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/locking: Revert "s3:locking: Remove dead code"
authorRalph Boehme <slow@samba.org>
Thu, 7 Apr 2022 09:10:15 +0000 (11:10 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 9 Dec 2022 23:11:38 +0000 (23:11 +0000)
This reverts commit de493a3e3b5b8d54f62c45072e27f2fefd4af43a:

    s3:locking: Remove dead code

    Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
dbwrap_do_locked() correctly returns saved_errno which is a possible
errno returned by close() inside fd_close_posix_fn().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/posix.c

index 9c76eb06ec5aa0068ad304f907835ebc4192ea47..ccc9d6276dabc3f0dd42e144e09a0c9af6a9cafb 100644 (file)
@@ -571,6 +571,8 @@ static void fd_close_posix_fn(
 
 int fd_close_posix(const struct files_struct *fsp)
 {
+       int saved_errno = 0;
+       int ret;
        NTSTATUS status;
 
        if (!lp_locking(fsp->conn->params) ||
@@ -615,7 +617,14 @@ int fd_close_posix(const struct files_struct *fsp)
         * Finally close the fd associated with this fsp.
         */
 
-       return close(fsp_get_pathref_fd(fsp));
+       ret = close(fsp_get_pathref_fd(fsp));
+
+       if (ret == 0 && saved_errno != 0) {
+               errno = saved_errno;
+               ret = -1;
+       }
+
+       return ret;
 }
 
 /****************************************************************************