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 <pawelx.dobrowolski@intel.com>
This commit is contained in:
PawelX Dobrowolski 2022-12-05 15:37:28 +01:00 committed by Carles Cufí
commit 07052aba13

View file

@ -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;