smbd: Pass unparsed_path_length to symlink_reparse_buffer_marshall()
authorVolker Lendecke <vl@samba.org>
Fri, 14 Oct 2022 15:12:26 +0000 (17:12 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 22 Nov 2022 18:27:33 +0000 (18:27 +0000)
[MS-FSCC] 2.1.2.4 Symbolic Link Reparse Data Buffer lists this field
as reserved, but [MS-SMB2] 2.2.2.2.1 Symbolic Link Error Response is
the exact same format with the reserved field as UnparsedPathLength.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
libcli/smb/reparse_symlink.c
libcli/smb/reparse_symlink.h
source3/libsmb/clisymlink.c

index 04f26dc1162b0455420e17c1ae339b1b5c475a25..31a438013fcaa75145e5c85f07259588a6d4ab25 100644 (file)
 #include "lib/util/debug.h"
 
 bool symlink_reparse_buffer_marshall(
-       const char *substitute, const char *printname, uint32_t flags,
-       TALLOC_CTX *mem_ctx, uint8_t **pdst, size_t *pdstlen)
+       const char *substitute,
+       const char *printname,
+       uint16_t unparsed_path_length,
+       uint32_t flags,
+       TALLOC_CTX *mem_ctx,
+       uint8_t **pdst,
+       size_t *pdstlen)
 {
        uint8_t *dst = NULL;
        size_t dst_len;
@@ -87,7 +92,7 @@ bool symlink_reparse_buffer_marshall(
 
        SIVAL(dst, 0, IO_REPARSE_TAG_SYMLINK);     /* ReparseTag */
        SSVAL(dst, 4, 12 + subst_len + print_len); /* ReparseDataLength */
-       SSVAL(dst, 6, 0);                          /* Reserved */
+       SSVAL(dst, 6, unparsed_path_length);       /* Reserved */
        SSVAL(dst, 8, 0);                          /* SubstituteNameOffset */
        SSVAL(dst, 10, subst_len);                 /* SubstituteNameLength */
        SSVAL(dst, 12, subst_len);                 /* PrintNameOffset */
index b561fa9fc985f793d63e2673c004f2fe51d7c5a0..7791d71663e97915769535b05a6d9028460b9802 100644 (file)
@@ -34,8 +34,13 @@ struct symlink_reparse_struct {
 };
 
 bool symlink_reparse_buffer_marshall(
-       const char *substitute, const char *printname, uint32_t flags,
-       TALLOC_CTX *mem_ctx, uint8_t **pdst, size_t *pdstlen);
+       const char *substitute,
+       const char *printname,
+       uint16_t unparsed_path_length,
+       uint32_t flags,
+       TALLOC_CTX *mem_ctx,
+       uint8_t **pdst,
+       size_t *pdstlen);
 struct symlink_reparse_struct *symlink_reparse_buffer_parse(
        TALLOC_CTX *mem_ctx, const uint8_t *src, size_t srclen);
 
index 35a9c4069687c2762eb5763d0968c757327390dc..f77f2c050abf91f48ef2672ff3f7e117e5384eb6 100644 (file)
@@ -97,7 +97,7 @@ static void cli_symlink_create_done(struct tevent_req *subreq)
        }
 
        if (!symlink_reparse_buffer_marshall(
-                   state->link_target, NULL, state->flags, state,
+                   state->link_target, NULL, 0, state->flags, state,
                    &state->in.data, &state->in.length)) {
                tevent_req_oom(req);
                return;