Skip to content

[NETSH] Compare the stack entry against the tail, not the head twice - #9473

Merged
binarymaster merged 1 commit into
reactos:masterfrom
darkdi:netsh-stack-tail
Sep 5, 2026
Merged

binarymaster merged 1 commit into
reactos:masterfrom
darkdi:netsh-stack-tail

Conversation

@darkdi

@darkdi darkdi commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Purpose

RemoveContextFromStack tests pStackEntry == pContextStackHead twice in the same condition, so the first branch takes every entry that happens to be the head, not only the one that is head and tail at once. The branch below it, the one that relinks pStackEntry->pNext->pPrev and moves the head forward, is then unreachable. Removing the head of a stack that has more than one entry sets both head and tail to NULL and frees only that entry, so the remaining entries are lost and leaked.

The body of the first branch is what says which test was meant: it clears both ends, and that is only correct for the single element case.

Proposed changes

  • Compare the second test against pContextStackTail

I found this by reading, not by hitting it in a running netsh session, so I have not confirmed the leak on a live context stack.

@binarymaster binarymaster added the trivial fix For trivial changes. label Sep 1, 2026
@github-project-automation github-project-automation Bot moved this from New PRs to Approved by reviewers in ReactOS PRs Sep 1, 2026
@github-project-automation github-project-automation Bot moved this to New PRs in ReactOS PRs Sep 1, 2026

@binarymaster binarymaster left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
Thanks for your interest in ReactOS!
We ask our contributors to use their full name when committing.
Your commits are authored correctly, however your GitHub account needs to be configured accordingly, so maintainers can use Squash & Merge button without getting the author field modified back to nickname by GitHub, it's done in two steps:

  1. Set your full name in GitHub profile settings (it should match your user.name setting)
  2. Uncheck Keep my email addresses private in GitHub email settings

Regards,

@github-project-automation github-project-automation Bot moved this from Approved by reviewers to WIP / Waiting on contributor in ReactOS PRs Sep 1, 2026
@darkdi

darkdi commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Understood, the profile Name field says just "Dmitry" while the commits say "Dmitry Rantovov". I will set it to the full name so Squash & Merge keeps the author, and I will ping here once it is done rather than force pushing anything.

@HBelusca
HBelusca requested a review from EricKohl September 1, 2026 12:00
@darkdi

darkdi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Profile name is now the full "Dmitry Rantovov", so a squash merge will keep the author the commit already has. The email on the commit is linked to the account too, that was missing before and it is why the commit showed as unattributed.

@binarymaster

Copy link
Copy Markdown
Member

@darkdi can confirm the name is set correctly now.

However email step is still needed:

image

@darkdi

darkdi commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Done, the setting is off now. The commit here is authored as Dmitry Rantovov [email protected] and that address is verified on the account, so a squash merge should keep it as is.

@github-project-automation github-project-automation Bot moved this from WIP / Waiting on contributor to Approved by reviewers in ReactOS PRs Sep 5, 2026
@binarymaster
binarymaster merged commit b91b138 into reactos:master Sep 5, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Approved by reviewers to Done in ReactOS PRs Sep 5, 2026
@binarymaster

Copy link
Copy Markdown
Member

Thanks!

ahmedarif193 pushed a commit to LiberNT/LiberNT that referenced this pull request Oct 9, 2026
…eactos#9473)

RemoveContextFromStack tests pStackEntry == pContextStackHead twice
in the same condition, so the first branch takes every entry that happens
to be the head, not only the one that is head and tail at once.
The branch below it, the one that relinks pStackEntry->pNext->pPrev and
moves the head forward, is then unreachable. Removing the head of a stack
that has more than one entry sets both head and tail to NULL and frees
only that entry, so the remaining entries are lost and leaked.

The body of the first branch is what says which test was meant:
it clears both ends, and that is only correct for the single element case.

Compare the second test against pContextStackTail.

I found this by reading, not by hitting it in a running netsh session,
so I have not confirmed the leak on a live context stack.

Reviewed-by: Whindmar Saksit <[email protected]>
Reviewed-by: Hermès Bélusca-Maïto <[email protected]>
Reviewed-by: Eric Kohl <[email protected]>
Signed-off-by: Dmitry Rantovov <[email protected]>
(cherry picked from commit b91b138)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trivial fix For trivial changes.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants