Repository navigation
fix(stats): guard num_open decrement against underflow - #648
Merged
Merged
Conversation
Contributor
|
the docs change with your personal audit is unwanted; once you removed it i will review the PR. |
STAT_CLOSE unconditionally decremented num_open (unsigned long), but STAT_BADCONN and other error paths can trigger conn_destroy_contents -> STAT_CLOSE without a prior conn_init_contents -> STAT_OPEN. This caused num_open to wrap to ULONG_MAX, skewing all statistics. Add a guard to only decrement when num_open > 0.
code1a2024
force-pushed
the
fix/stats-underflow-guard
branch
from
November 18, 2026 02:53
0b662c2 to
73f362a
Compare
Contributor
Author
I'm so sorry. Now the commit is updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
STAT_CLOSE unconditionally decremented num_open (unsigned long),
but error paths like STAT_BADCONN can trigger conn_destroy_contents
→ STAT_CLOSE without a prior conn_init_contents → STAT_OPEN. This
causes num_open to wrap to ULONG_MAX, permanently skewing the
"Number of open connections" display on the stats page.
Fix: only decrement num_open when it is greater than zero, matching
the guard the caller already has in conn_destroy_contents.
Changes: 1 file, +2/-1 (stats.c)