microsoft / microsoft/SysmonForLinux

fix: prevent division by zero in intHandler when no events received

Aperta
#230 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.