Static analysis reports that in add_region(), a buffer from pread() won't have NUL-termination. Hence passing it to strtol subsequently can be wrong. Manually add the termination after pread() to fix this.
Fixes: c64cc150a21e ("ndctl: add support in libndctl to provide deep flush") Cc: Dave Jiang <dave.ji...@intel.com> Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com> --- ndctl/lib/libndctl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index f32f704..ddbdd9a 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -2750,6 +2750,8 @@ static void *add_region(void *parent, int id, const char *region_base) goto out; } + /* pread() doesn't add NUL termination */ + buf[1] = 0; perm = strtol(buf, NULL, 0); if (perm == 0) { close(region->flush_fd); -- 2.39.0