34 lines
1.1 KiB
Diff
34 lines
1.1 KiB
Diff
|
|
From 2f99e11812e6a4d9814bfc8ef038ca845db5394c Mon Sep 17 00:00:00 2001
|
||
|
|
From: Vishal Verma <vishal.l.verma@intel.com>
|
||
|
|
Date: Thu, 1 Oct 2020 11:10:00 -0600
|
||
|
|
Subject: [PATCH 2/2] libndctl: fix a potential buffer overflow
|
||
|
|
|
||
|
|
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 ee737cb..5b276a7 100644
|
||
|
|
--- a/ndctl/lib/libndctl.c
|
||
|
|
+++ b/ndctl/lib/libndctl.c
|
||
|
|
@@ -3292,8 +3292,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",
|
||
|
|
--
|
||
|
|
1.8.3.1
|
||
|
|
|