From: Alison Schofield <[email protected]> A coverity scan highlighted an integer underflow when param.align is 0, and an integer overflow when the parsing of param.align fails and returns ULLONG_MAX.
Add explicit checks for both values. Signed-off-by: Alison Schofield <[email protected]> --- ndctl/namespace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 40bcf4ca65ac..3224c9ff4444 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -2086,7 +2086,11 @@ static int namespace_rw_infoblock(struct ndctl_namespace *ndns, unsigned long long size = parse_size64(param.size); align = parse_size64(param.align); - if (align < ULLONG_MAX && !IS_ALIGNED(size, align)) { + if (align == 0 || align == ULLONG_MAX) { + error("invalid alignment:%s\n", param.align); + rc = -EINVAL; + } + if (!IS_ALIGNED(size, align)) { error("--size=%s not aligned to %s\n", param.size, param.align); -- 2.37.3
