nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [ndctl PATCH 1/2] libndctl: fix a potential buffer overflow
@ 2020-10-01 19:38 Vishal Verma
  2020-10-01 19:38 ` [ndctl PATCH 2/2] ndctl/inject-error: remove logically dead code Vishal Verma
  0 siblings, 1 reply; 2+ messages in thread
From: Vishal Verma @ 2020-10-01 19:38 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Dan Williams, Vishal Verma

Static analysis points out that the 'buf' in ndctl_dimm_is_active was
inappropriately sized. We already have 'SYSFS_ATTR_SIZE' for such
buffers, and it looks like this was just an oversight.

Fixes: 0a4509d7de2f ("ndctl: enumerate interleave sets")
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/lib/libndctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 6556b33..5546963 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -3675,8 +3675,8 @@ NDCTL_EXPORT int ndctl_dimm_is_active(struct ndctl_dimm *dimm)
 {
 	struct ndctl_ctx *ctx = ndctl_dimm_get_ctx(dimm);
 	char *path = dimm->dimm_buf;
+	char buf[SYSFS_ATTR_SIZE];
 	int len = dimm->buf_len;
-	char buf[20];
 
 	if (snprintf(path, len, "%s/state", dimm->dimm_path) >= len) {
 		err(ctx, "%s: buffer too small!\n",
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [ndctl PATCH 2/2] ndctl/inject-error: remove logically dead code
  2020-10-01 19:38 [ndctl PATCH 1/2] libndctl: fix a potential buffer overflow Vishal Verma
@ 2020-10-01 19:38 ` Vishal Verma
  0 siblings, 0 replies; 2+ messages in thread
From: Vishal Verma @ 2020-10-01 19:38 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Dan Williams, Vishal Verma

Static analysis reports that the bb != NULL check is redundant because
ndctl_namespace_bb_foreach already uses that as a loop condition. Remove
it.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/inject-error.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/ndctl/inject-error.c b/ndctl/inject-error.c
index fe599ef..f6be6a5 100644
--- a/ndctl/inject-error.c
+++ b/ndctl/inject-error.c
@@ -255,9 +255,6 @@ static int injection_status(struct ndctl_namespace *ndns)
 	}
 
 	ndctl_namespace_bb_foreach(ndns, bb) {
-		if (!bb)
-			break;
-
 		block = ndctl_bb_get_block(bb);
 		count = ndctl_bb_get_count(bb);
 		jbb = util_badblock_rec_to_json(block, count, ictx.json_flags);
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-01 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01 19:38 [ndctl PATCH 1/2] libndctl: fix a potential buffer overflow Vishal Verma
2020-10-01 19:38 ` [ndctl PATCH 2/2] ndctl/inject-error: remove logically dead code Vishal Verma

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