* [PATCH] edac: edac_mc_sysfs.c: Use strlcpy to Copy a C-string into a sized buffer
@ 2017-05-26 18:58 Karim Eshapa
0 siblings, 0 replies; only message in thread
From: Karim Eshapa @ 2017-05-26 18:58 UTC (permalink / raw)
To: bp; +Cc: mchehab, linux-edac, linux-kernel, Karim Eshapa
Use strlcpy with sized buffer instead of strncpy to
avoid non NUL-terminated source strings problems.
Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
---
drivers/edac/edac_mc_sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 445862d..64e2255 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -251,7 +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);
+ strlcpy(rank->dimm->label, data, copy_count);
rank->dimm->label[copy_count] = '\0';
return count;
@@ -530,7 +530,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);
+ strlcpy(dimm->label, data, copy_count);
dimm->label[copy_count] = '\0';
return count;
--
2.7.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-26 18:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 18:58 [PATCH] edac: edac_mc_sysfs.c: Use strlcpy to Copy a C-string into a sized buffer Karim Eshapa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).