[PATCH] fat: fat2rtc: Sanitize timestamps

Richard Weinberger richard at sigma-star.at
Fri Jul 12 11:51:06 CEST 2024


Am Freitag, 12. Juli 2024, 11:46:08 CEST schrieb 'Heinrich Schuchardt' via upstream: 
> Am 12. Juli 2024 10:24:54 MESZ schrieb Richard Weinberger <richard at nod.at>:
> >Make sure that tm_mday and tm_mon are within the expected
> >range. Upper layers such as rtc_calc_weekday() will use
> >them as lookup keys for arrays and this can cause out of
> >bounds memory accesses.
> 
> rtc_calc_weekday() might receive invalid input from other sources. Shouldn't the function always validate its input before array access?

It depends on the overall design.
Functions like strlen() also assume that you provide a valid string,
so rtc_calc_weekday() can assume too that the passed rtc_time structure contains valid data.

In doubt, let's fix both FAT and rtc_calc_weekday().

Thanks,
//richard

-- 
​​​​​sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT
UID/VAT Nr: ATU 66964118 | FN: 374287y




More information about the U-Boot mailing list