nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [ndctl PATCH] ndctl, sysfs: null terminate buffer on error
@ 2018-03-20 20:44 Dan Williams
  0 siblings, 0 replies; only message in thread
From: Dan Williams @ 2018-03-20 20:44 UTC (permalink / raw)
  To: linux-nvdimm

Terminate the buffer for sysfs_read_attr() users that might not
properly handle the error code.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 util/sysfs.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/util/sysfs.c b/util/sysfs.c
index e067f065a820..0440fd0f49a3 100644
--- a/util/sysfs.c
+++ b/util/sysfs.c
@@ -39,6 +39,7 @@ int __sysfs_read_attr(struct log_ctx *ctx, const char *path, char *buf)
 	n = read(fd, buf, SYSFS_ATTR_SIZE);
 	close(fd);
 	if (n < 0 || n >= SYSFS_ATTR_SIZE) {
+		buf[0] = 0;
 		log_dbg(ctx, "failed to read %s: %s\n", path, strerror(errno));
 		return -errno;
 	}

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-20 20:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20 20:44 [ndctl PATCH] ndctl, sysfs: null terminate buffer on error Dan Williams

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).