From 7e09a57b395dc88af218873fd7f47c99c0542f4f Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Fri, 12 Jun 2020 09:39:46 -0700 Subject: [PATCH] stress/sizes: Fix an off-by-one issue. Algorithmically, a size greater than 1024 ZB could access one-past-the-end of the sizes array. This couldn't really happen since SIZE_MAX is less than 1024 ZB on all platforms we support (and we pick the arguments to this function to be reasonable anyways), but it's not like there's any reason *not* to fix it, either. --- test/stress/sizes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stress/sizes.c b/test/stress/sizes.c index 1bdfe160..44c9de5e 100644 --- a/test/stress/sizes.c +++ b/test/stress/sizes.c @@ -17,7 +17,7 @@ do_print(const char *name, size_t sz_bytes) { size_t ind = 0; double sz = sz_bytes; - while (sz >= 1024 && ind < sizes_max) { + while (sz >= 1024 && ind < sizes_max - 1) { sz /= 1024; ind++; }