]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Fix cosmetic bug logging pathnames from Linux kernel clients using SMB1...
authorJeremy Allison <jra@samba.org>
Sat, 6 Aug 2022 02:27:33 +0000 (19:27 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 12 Aug 2022 18:19:30 +0000 (18:19 +0000)
The Linux kernel SMB1 client has a bug - it sends
DFS pathnames as:

\\server\share\path

instead of:

\server\share\path

Causing us to mis-parse server,share,remaining_path here
and jump into 'goto local_path' at 'share\path' instead
of 'path'.

This doesn't cause an error as the limits on share names
are similar to those on pathnames.

parse_dfs_path() which we call before filename parsing
copes with this by calling trim_char on the leading '\'
characters before processing.

Do the same here so logging of pathnames looks better.

How did I find this ? Lots and lots of manual
testing with the Linux kernel client to make
sure all the recent changes haven't broken Linux
SMB1/2/3 DFS :-).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144

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

index 42601879c098e702dd2c87b56a6b2e2b23a62681..870c3bcb898bc90aa195d308e703b605ef3f459b 100644 (file)
@@ -310,6 +310,29 @@ static size_t srvstr_get_path_internal(TALLOC_CTX *ctx,
                 */
                server = dst;
 
+               /*
+                * Cosmetic fix for Linux-only DFS clients.
+                * The Linux kernel SMB1 client has a bug - it sends
+                * DFS pathnames as:
+                *
+                * \\server\share\path
+                *
+                * Causing us to mis-parse server,share,remaining_path here
+                * and jump into 'goto local_path' at 'share\path' instead
+                * of 'path'.
+                *
+                * This doesn't cause an error as the limits on share names
+                * are similar to those on pathnames.
+                *
+                * parse_dfs_path() which we call before filename parsing
+                * copes with this by calling trim_char on the leading '\'
+                * characters before processing.
+                * Do the same here so logging of pathnames looks better.
+                */
+               if (server[1] == path_sep) {
+                       trim_char(&server[1], path_sep, '\0');
+               }
+
                /*
                 * Look to see if we also have /share following.
                 */