Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#230 0 comments 0 reactions 1 assignee View on GitHub

@MarioHewardt is already working on this.

Since Apr 4, 2026.

Assessment

This issue has not been assessed yet.

Description

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)
Dominant language
C
Stars
2.2k
Forks
220
Avg merge
11d 22h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/SysmonForLinux

All issues in microsoft/SysmonForLinux

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.