On Wed, Oct 14, 2026 at 07:47:16PM +0200, Vincent Stehlé wrote:
> Depending on its input structure's tm_mon field value, the
> rtc_calc_weekday() function may read the month_offset[] array it uses
> for its computations out of its bounds.
> Verify tm_mon on input to prevent that.

The FAT date has a 4-bit month field, so fat2rtc() can pass 0 or 13..15
here from a corrupted directory entry.

I built rtc_calc_weekday() on the host with -fsanitize=address,undefined.
Before this patch, tm_mon = 0 gives "index -1 out of bounds for type
'int [12]'"; with it, tm_mon = 0, 13 and 15 return -1, and 2026-10-15
still gives tm_wday = 4 (Thursday).

Reviewed-by: Hung-Chun Tseng <[email protected]>

Reply via email to