microsoft / microsoft/SysmonForLinux
fix: prevent division by zero in intHandler when no events received
Aperta
@MarioHewardt ci sta già lavorando.
Dal 4/4/2026.
- Lingua principale
- C
- Stelle
- 2.2k
- Fork
- 220
- Merge medio
- 11g 22h
- PR unite (30g)
- 2
Descrizione
Summary
Fix a potential division by zero crash in the intHandler signal
handler when Sysmon is stopped before processing any events
(totalEvents == 0).
Problem
In intHandler(), the following line:
printf("Total events: %ld, bad events: %ld, ratio = %f\n",
totalEvents, badEvents, (double)badEvents / totalEvents);
...will produce a division by zero (resulting in NaN or crash) if
Sysmon is interrupted immediately after startup before any eBPF
events are received.
Fix
Guard the division with a ternary check:
(double)badEvents / totalEvents
→
totalEvents > 0 ? (double)badEvents / totalEvents : 0.0
Testing
- Start Sysmon and immediately send SIGINT (Ctrl+C)
- Confirm clean output showing ratio = 0.000000 instead of crash/NaN
Notes
- No functional change to normal operation
- Zero risk of regression
- Fixes undefined behavior per C standard (integer division by zero)
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.