fix: prevent crash in authenticate() when register() fails#56
Open
toddr-bot wants to merge 2 commits into
Open
fix: prevent crash in authenticate() when register() fails#56toddr-bot wants to merge 2 commits into
toddr-bot wants to merge 2 commits into
Conversation
Member
|
@toddr-bot rebase |
authenticate() dereferences the return value of register() as a hashref without checking if it's actually a reference. When register() fails (returning undef), this causes a fatal error: "Can't use an undefined value as a HASH ref" Also fix disconnect() to properly close the socket and clean up the IO::Select reference and connection state. Previously, the socket was never explicitly closed — the comment "# _send closes socket" was wrong since closesock=0 was passed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Rebase with requested adjustmentsBranch StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
7922aae to
7fe5493
Compare
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.
What
Fix two bugs in the Core.pm network layer: a crash in authenticate() and a socket leak in disconnect().
Why
When a Razor server returns error 213 (unknown user), authenticate() tries to re-register. If register() fails (returns undef), the code immediately dereferences the return value as a hashref (
$id->{user}), causing a fatal crash. This affects users whose identity is lost on the server side — instead of a graceful error, the client dies.The disconnect() method also had a bug: it passed
closesock=0to_send()and thendeleted the socket reference without actually closing it. The IO::Select object still held a reference, leaking the file descriptor until GC. The comment "# _send closes socket" was misleading.How
ref($id) eq 'HASH'guard before dereferencing register()'s return valuesock,select,connected_to)Testing
t/core.twith tests for both bugs🤖 Generated with Claude Code