From 2385ffcafdd41ea2262862a61e0ea0e6b426fda7 Mon Sep 17 00:00:00 2001 From: linqiheng Date: Tue, 10 Jan 2023 07:48:53 +0000 Subject: [PATCH] hmdfs: fix memcpy reads d_name out of bounds Signed-off-by: linqiheng --- fs/hmdfs/inode_root.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hmdfs/inode_root.c b/fs/hmdfs/inode_root.c index 30d0ca6a2264..b3b2b5c2b2fc 100644 --- a/fs/hmdfs/inode_root.c +++ b/fs/hmdfs/inode_root.c @@ -153,7 +153,7 @@ struct dentry *hmdfs_device_lookup(struct inode *parent_inode, ret_dentry = ERR_PTR(err); goto out; } - memcpy(cid, d_name, HMDFS_CID_SIZE); + strncpy(cid, d_name, HMDFS_CID_SIZE); cid[HMDFS_CID_SIZE] = '\0'; con = hmdfs_lookup_from_cid(sbi, cid); if (!con) { -- Gitee