Fix SIPParseError crash when OPTIONS arrives mid-INVITE-transaction - #319
Open
hainesdev wants to merge 1 commit into
Open
Fix SIPParseError crash when OPTIONS arrives mid-INVITE-transaction#319hainesdev wants to merge 1 commit into
hainesdev wants to merge 1 commit into
Conversation
Fixes tayler6000#315 [FIX] Added OPTIONS to SIPCompatibleMethods. SIPMessage.parse() raised SIPParseError for any method not in this list. SIPClient.recv() (the background receive loop) happens to swallow that exception, but invite()'s own blocking response read does not, so a server-initiated OPTIONS request (e.g. Asterisk's periodic qualify keepalive) landing mid-INVITE-transaction crashed the whole call. parse_message() already has a graceful fallback for unrecognized methods once parsing succeeds, so this only needed to stop parse() from raising in the first place.
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.
Fixes #315
SIPCompatibleMethodsdidn't includeOPTIONS, soSIPMessage.parse()raisedSIPParseErrorfor any incoming OPTIONS request.SIPClient.recv()(the background receive loop) happens to swallow that exception via its broadexcept Exception, butinvite()'s own blocking response-read loop does not -- so a server-initiated OPTIONS request (e.g. Asterisk's periodic qualify keepalive to a registered contact) landing at the exact momentinvite()is waiting on the INVITE transaction's response crashes the entire call attempt.Confirmed live against a real Asterisk PBX:
Related to #73, which covers full OPTIONS support and per that thread has been done in
developmentfor 2.0 -- this is scoped narrower, to just stopmaster/1.6.x (still what's on PyPI) from hard-crashing on receipt of one. It doesn't need full handling:parse_message()already has a graceful fallback for unrecognized methods once parsing succeeds (else: debug("TODO: Add 400 Error on non processable request")), it's onlySIPMessage.parse()itself that fails first.Fix just adds
"OPTIONS"toSIPCompatibleMethodsso it routes through the existing generic parser instead of raising.