]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Some more assert in fd_openat()
authorVolker Lendecke <vl@samba.org>
Tue, 14 Jun 2022 14:15:15 +0000 (16:15 +0200)
committerRalph Boehme <slow@samba.org>
Mon, 25 Jul 2022 12:04:33 +0000 (12:04 +0000)
Before this patch we asserted that if we have a base_fsp then
smb_fname must have a stream name attached. Now we also assert that if
we don't have a base_fsp smb_fname is not a stream.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index 16e691766e578602a31a79449f87702725f2e100..3a8c0bf9c48537fba47560f8ae3c6c42711136d5 100644 (file)
@@ -879,6 +879,10 @@ NTSTATUS fd_openat(const struct files_struct *dirfsp,
 {
        struct connection_struct *conn = fsp->conn;
        NTSTATUS status = NT_STATUS_OK;
+       bool fsp_is_stream = fsp_is_alternate_stream(fsp);
+       bool smb_fname_is_stream = is_named_stream(smb_fname);
+
+       SMB_ASSERT(fsp_is_stream == smb_fname_is_stream);
 
        /*
         * Never follow symlinks on a POSIX client. The
@@ -889,11 +893,9 @@ NTSTATUS fd_openat(const struct files_struct *dirfsp,
                flags |= O_NOFOLLOW;
        }
 
-       if (fsp_is_alternate_stream(fsp)) {
+       if (fsp_is_stream) {
                int fd;
 
-               SMB_ASSERT(is_named_stream(smb_fname));
-
                fd = SMB_VFS_OPENAT(
                        conn,
                        NULL,   /* stream open is relative to fsp->base_fsp */