From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH] ndctl, sysfs: null terminate buffer on error
Date: Tue, 20 Mar 2018 13:44:37 -0700 [thread overview]
Message-ID: <152157867701.19898.6466178424544300544.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
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
reply other threads:[~2018-03-20 20:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=152157867701.19898.6466178424544300544.stgit@dwillia2-desk3.amr.corp.intel.com \
--to=dan.j.williams@intel.com \
--cc=linux-nvdimm@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.