Skip to content

Fix SIPParseError crash when OPTIONS arrives mid-INVITE-transaction - #319

Open
hainesdev wants to merge 1 commit into
tayler6000:masterfrom
hainesdev:bugfix/Issue-315
Open

Fix SIPParseError crash when OPTIONS arrives mid-INVITE-transaction#319
hainesdev wants to merge 1 commit into
tayler6000:masterfrom
hainesdev:bugfix/Issue-315

Conversation

@hainesdev

Copy link
Copy Markdown

Fixes #315

SIPCompatibleMethods didn't include OPTIONS, so SIPMessage.parse() raised SIPParseError for any incoming OPTIONS request. SIPClient.recv() (the background receive loop) happens to swallow that exception via its broad except Exception, but invite()'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 moment invite() is waiting on the INVITE transaction's response crashes the entire call attempt.

Confirmed live against a real Asterisk PBX:

pyVoIP.SIP.SIPParseError: Unable to decipher SIP request: OPTIONS sip:101@x.x.x.x:5060 SIP/2.0

Related to #73, which covers full OPTIONS support and per that thread has been done in development for 2.0 -- this is scoped narrower, to just stop master/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 only SIPMessage.parse() itself that fails first.

Fix just adds "OPTIONS" to SIPCompatibleMethods so it routes through the existing generic parser instead of raising.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIPClient.invite() crashes with SIPParseError if an OPTIONS request arrives mid-transaction (master/1.6.x)

1 participant