fix: prevent Poco::InvalidArgumentException crash in peer module#491
Merged
fix: prevent Poco::InvalidArgumentException crash in peer module#491
Conversation
2efdfc1 to
3422bff
Compare
This commit fixes a critical crash caused by unhandled Poco::InvalidArgumentException when processing peer messages with invalid IP addresses or ports. Changes: 1. Added exception handling in Peer::handlePubInfo (peer/peer.cc) - Catch Poco::Exception when constructing SocketAddress - Log detailed error information (IP, port, error message) - Return early to prevent invalid state propagation 2. Added exception handling in PeerManager::handlePubInfo (peer/manager.cc) - Wrap peer map operations in try-catch - Catch both Poco::Exception and std::exception - Log source peer IP and detailed error context 3. Added exception handling in PeerManager::handlePeerQueue (peer/manager.cc) - Wrap entire message handling switch in try-catch - Log message type and error information - Return 0 to continue processing instead of crashing 4. Fixed websocket close frame logging (websocket/client.cc) - Changed from direct buffer output to hex format - Prevents systemd journalctl from showing "blob data" 5. Bumped version to 6.1.7 Root Cause: When receiving network messages with invalid IP addresses (e.g., all zeros), Poco::Net::SocketAddress constructor throws Poco::InvalidArgumentException. This exception was uncaught in the message processing thread, causing std::terminate() to be called and the program to crash. Impact: - Prevents crash when processing invalid peer messages - Provides detailed error logging for debugging - Allows program to continue running instead of terminating - Version: 6.1.7 Tested: Compiles successfully with no warnings
3422bff to
ef58449
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.
This commit fixes a critical crash caused by unhandled Poco::InvalidArgumentException when processing peer messages with invalid IP addresses or ports.
Changes:
Added exception handling in Peer::handlePubInfo (peer/peer.cc)
Added exception handling in PeerManager::handlePubInfo (peer/manager.cc)
Added exception handling in PeerManager::handlePeerQueue (peer/manager.cc)
Fixed websocket close frame logging (websocket/client.cc)
Root Cause:
When receiving network messages with invalid IP addresses (e.g., all zeros), Poco::Net::SocketAddress constructor throws Poco::InvalidArgumentException. This exception was uncaught in the message processing thread, causing std::terminate() to be called and the program to crash.
Impact:
Tested: Compiles successfully with no warnings