]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Ensure errno is preserved across fsp destructor
authorSachin Prabhu <sprabhu@redhat.com>
Wed, 10 Mar 2021 12:22:07 +0000 (12:22 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Mar 2021 22:55:17 +0000 (22:55 +0000)
The errno can be overwritten by the calls made by the fsp destructor.
This can cause problems if the original errno was required by subsequent
calls.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Mar 10 22:55:17 UTC 2021 on sn-devel-184

source3/smbd/files.c

index 8e01815531d2806a72c91049398a4d025e5df580..b13d151a876c95448573b72f249c9f604420f960 100644 (file)
@@ -358,10 +358,12 @@ static int smb_fname_fsp_destructor(struct smb_filename *smb_fname)
 {
        struct files_struct *fsp = smb_fname->fsp;
        NTSTATUS status;
+       int saved_errno = errno;
 
        destroy_fsp_smb_fname_link(&smb_fname->fsp_link);
 
        if (fsp == NULL) {
+               errno = saved_errno;
                return 0;
        }
 
@@ -380,6 +382,7 @@ static int smb_fname_fsp_destructor(struct smb_filename *smb_fname)
        file_free(NULL, fsp);
        smb_fname->fsp = NULL;
 
+       errno = saved_errno;
        return 0;
 }