Variable *histogram->total_count with floating-point type whose possible value set allows a zero value at redis-cli.c:10449 by calling function 'hdr_init' is passed to function at redis-cli.c:10544, where it is used as a denominator at redis-cli.c:10219 by calling function 'hdr_stddev'. The result of division is further used without a check for NaN, which leads to undefined program behavior.
Line 10449 in void KeyStats at redis-cli:c https://github.com/redis/redis/blob/8.0.3/src/redis-cli.c#L10449
hdr_init(1, 1ULL*1024*1024*1024*1024, 4, &keysize_histogram)
Where hdr_init include void hdr_init_preallocated
h->total_count = 0;
Line 10544 at redis-cli.c https://github.com/redis/redis/blob/8.0.3/src/redis-cli.c#L10544
displayKeyStatsSizeDist(keysize_histogram);
Line 10219 at redis-cli.c
bytesToHuman(stddev, sizeof(stddev),hdr_stddev(keysize_histogram));
Line in 754 /deps/hdr_histogram/hdr_histogram.c, where function hdr_mean is called, whose description includes division, in which the denominator can be 0 (h->total_count) :
return (total * 1.0) / h->total_count;
https://github.com/redis/redis/blob/8.0.3/deps/hdr_histogram/hdr_histogram.c#L749
It is recommended to include null check.
Found by Linux Verification Center ( linuxtesting.org) with SVACE Reporter: Gushchin Egor ( guschin058@yandex.ru )