FreeRTOS-Kernel/portable/MSVC-MingW
AniruddhaKanhere 5b6c2f29db MSVC-MingW: bounds-check interrupt number in FromWindowsThread path
Defect: vPortGenerateSimulatedInterruptFromWindowsThread() in the MSVC-MingW
simulator port performs a shift by a caller-supplied interrupt number without
range checking it, giving undefined behavior for out-of-range values.

Root cause: the function pends an interrupt via ( 1UL << ulInterruptNumber )
into ulPendingInterrupts, but does not verify ulInterruptNumber is within the
width of that variable. A value greater than or equal to portMAX_INTERRUPTS
makes the shift undefined. The task-context sibling
vPortGenerateSimulatedInterrupt() already performs this bounds check.

Fix: gate the operation on ( ulInterruptNumber < portMAX_INTERRUPTS ) in
addition to the existing xPortRunning check, mirroring the task-context sibling
so both entry points are consistent.

A host regression test kept outside this repository demonstrates the fault
before the change and its absence afterwards (red then green).
2026-07-09 12:02:29 -07:00
..
port.c MSVC-MingW: bounds-check interrupt number in FromWindowsThread path 2026-07-09 12:02:29 -07:00
portmacro.h Move windows headers to port.c (#1302) 2025-08-05 19:11:54 +08:00