lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1495825821-5295-1-git-send-email-karim.eshapa@gmail.com>
Date:   Fri, 26 May 2017 21:10:21 +0200
From:   Karim Eshapa <karim.eshapa@...il.com>
To:     bp@...en8.de
Cc:     mchehab@...nel.org, linux-edac@...r.kernel.org,
        linux-kernel@...r.kernel.org, Karim Eshapa <karim.eshapa@...il.com>
Subject: [PATCH v2] edac: edac_mc_sysfs.c: Use strlcpy to Copy a C-string into a sized buffer

Use strlcpy with sized buffer instead of strncpy to
avoid non NUL-terminated source strings problems.

Signed-off-by: Karim Eshapa <karim.eshapa@...il.com>
---
 drivers/edac/edac_mc_sysfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 445862d..e893b94 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -251,8 +251,7 @@ static ssize_t channel_dimm_label_store(struct device *dev,
 	if (copy_count == 0 || copy_count >= sizeof(rank->dimm->label))
 		return -EINVAL;
 
-	strncpy(rank->dimm->label, data, copy_count);
-	rank->dimm->label[copy_count] = '\0';
+	strlcpy(rank->dimm->label, data, copy_count);
 
 	return count;
 }
@@ -530,8 +529,7 @@ static ssize_t dimmdev_label_store(struct device *dev,
 	if (copy_count == 0 || copy_count >= sizeof(dimm->label))
 		return -EINVAL;
 
-	strncpy(dimm->label, data, copy_count);
-	dimm->label[copy_count] = '\0';
+	strlcpy(dimm->label, data, copy_count);
 
 	return count;
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ