smbd: Make non_widelink_open() robust for non-cwd dirfsp
authorVolker Lendecke <vl@samba.org>
Wed, 9 Mar 2022 11:58:40 +0000 (12:58 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 23 Mar 2022 16:57:28 +0000 (16:57 +0000)
If you pass in dirfsp!=conn->cwd_fsp and a stream fsp, we don't chdir
to the parent pathname, and thus we also don't overwrite
fsp->base_fsp.

fsp->base_fsp!=NULL is thus the wrong condition to restore the
original base fsp name: If we open a stream with a non-cwd_fsp dirfsp,
we would overwrite fsp->base_fsp->fsp_name with NULL.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c

index d01b5ae65f4ca552fdef53bdb7c72475b7746797..3995a0beb35e677c281ac833b14d68fbf6fd4bf6 100644 (file)
@@ -891,7 +891,8 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
 
   out:
        fsp->fsp_name = orig_fsp_name;
-       if (fsp->base_fsp != NULL) {
+
+       if (orig_base_fsp_name != NULL) {
                /* Save off the temporary name. */
                struct smb_filename *base_smb_fname_rel =
                        fsp->base_fsp->fsp_name;