sd-event: add assert to help static analysis trace signal bounds

Coverity flags the signal_sources array access as a potential
out-of-bounds read because it cannot trace through the SIGNAL_VALID()
macro to know that ssi_signo < _NSIG. Add an explicit assert after
the runtime check to make the constraint visible to static analyzers.

CID#1548033

Follow-up for 7a64c5f23e
This commit is contained in:
Luca Boccassi
2026-03-28 19:52:09 +00:00
parent be85048e28
commit c8b53fcfd3

View File

@@ -3807,6 +3807,9 @@ static int process_signal(sd_event *e, struct signal_data *d, uint32_t events, i
if (_unlikely_(!SIGNAL_VALID(si.ssi_signo)))
return -EIO;
/* Silence static analyzers */
assert(si.ssi_signo < _NSIG);
if (e->signal_sources)
s = e->signal_sources[si.ssi_signo];
if (!s)