]> Pileus Git - ~andy/linux/commitdiff
cifs: using strlcpy instead of strncpy
authorZhao Hongjiang <zhaohongjiang@huawei.com>
Mon, 24 Jun 2013 06:57:47 +0000 (01:57 -0500)
committerSteve French <smfrench@gmail.com>
Wed, 26 Jun 2013 22:25:20 +0000 (17:25 -0500)
for NUL terminated string, need alway set '\0' in the end.

Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/connect.c
fs/cifs/smb2pdu.c

index d5f866afe560c39e5e7c7f5fb64e910dec3b33dd..53a1780cd0731c4eaf5c6bc56dc33e224d9d8b64 100644 (file)
@@ -3732,7 +3732,7 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
                }
                bcc_ptr += length + 1;
                bytes_left -= (length + 1);
-               strncpy(tcon->treeName, tree, MAX_TREE_SIZE);
+               strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
 
                /* mostly informational -- no need to fail on error here */
                kfree(tcon->nativeFileSystem);
index f7422a68b1638950bb843265c71bc80a29af8b52..92fd6c59c1257861991adc391cfb90c6891b1dfb 100644 (file)
@@ -746,7 +746,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
        tcon->tidStatus = CifsGood;
        tcon->need_reconnect = false;
        tcon->tid = rsp->hdr.TreeId;
-       strncpy(tcon->treeName, tree, MAX_TREE_SIZE);
+       strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
 
        if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) &&
            ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0))