From 07052aba13aa7aa45a1a326c85b1c9f5a559e306 Mon Sep 17 00:00:00 2001 From: PawelX Dobrowolski Date: Mon, 5 Dec 2022 15:37:28 +0100 Subject: [PATCH] logging: days in months calculation fix Array 'days_in_month' of size 12 may use index value bigger then count of its elements. Signed-off-by: PawelX Dobrowolski --- subsys/logging/log_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/logging/log_output.c b/subsys/logging/log_output.c index b1173a97c22..2d0a6a978cb 100644 --- a/subsys/logging/log_output.c +++ b/subsys/logging/log_output.c @@ -194,7 +194,7 @@ static void __attribute__((unused)) get_YMD_from_seconds(uint64_t seconds, output_date->year++; } /* compute the proper month */ - for (i = 0; i < sizeof(days_in_month); i++) { + for (i = 0; i < ARRAY_SIZE(days_in_month); i++) { tmp = ((i == 1) && is_leap_year(output_date->year)) ? (days_in_month[i] + 1) * SECONDS_IN_DAY : days_in_month[i] * SECONDS_IN_DAY;