smb3: Incorrect size for netname negotiate context
authorSteve French <stfrench@microsoft.com>
Mon, 5 Aug 2019 22:07:26 +0000 (17:07 -0500)
committerSteve French <stfrench@microsoft.com>
Mon, 16 Sep 2019 16:43:37 +0000 (11:43 -0500)
It is not null terminated (length was off by two).

Also see similar change to Samba:

https://gitlab.com/samba-team/samba/merge_requests/666

Reported-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/smb2pdu.c

index a653c429e8dcaebe98a5fecc70b7d5b41becf3c9..a33cb91b4963223a1f760527faf482df36d6c059 100644 (file)
@@ -503,8 +503,7 @@ build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname)
        pneg_ctxt->ContextType = SMB2_NETNAME_NEGOTIATE_CONTEXT_ID;
 
        /* copy up to max of first 100 bytes of server name to NetName field */
-       pneg_ctxt->DataLength = cpu_to_le16(2 +
-               (2 * cifs_strtoUTF16(pneg_ctxt->NetName, hostname, 100, cp)));
+       pneg_ctxt->DataLength = cpu_to_le16(2 * cifs_strtoUTF16(pneg_ctxt->NetName, hostname, 100, cp));
        /* context size is DataLength + minimal smb2_neg_context */
        return DIV_ROUND_UP(le16_to_cpu(pneg_ctxt->DataLength) +
                        sizeof(struct smb2_neg_context), 8) * 8;