libndctl: fix a potential buffer overflow
Vishal Verma
maintainerPATCH 1/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 <[email protected]>
Signed-off-by Vishal Verma <[email protected]>
--- ndctl/lib/libndctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ndctl/lib/libndctl.c +1 -1
@@ -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",
Signature · 4 lines
2.26.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Vishal Verma
maintainerPATCH 2/2 ndctl/inject-error: remove logically dead code
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 <[email protected]>
--- ndctl/inject-error.c | 3 --- 1 file changed, 3 deletions(-)
ndctl/inject-error.c +0 -3
@@ -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);
Signature · 4 lines
2.26.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]