From d0b2501a379dcf25cfcfe7059e9dc54b9c5ada4f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 7 Sep 2018 07:19:34 -0700 Subject: [PATCH] num2str(): Avoid an out-of-bounds array access This patch fixes Coverity ID 169307. Fixes: 1ec3d69b0ed8 ("Implement a better num2str()") Signed-off-by: Bart Van Assche --- lib/num2str.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/num2str.c b/lib/num2str.c index ff8a365b..1abe22f3 100644 --- a/lib/num2str.c +++ b/lib/num2str.c @@ -72,7 +72,7 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, enum n2s_unit units) * Divide by K/Ki until string length of num <= maxlen. */ modulo = -1U; - while (post_index < sizeof(sistr)) { + while (post_index < ARRAY_SIZE(sistr)) { sprintf(tmp, "%llu", (unsigned long long) num); if (strlen(tmp) <= maxlen) break; -- 2.25.1