nua: parse inbound multipart bodies into the request home, not the handle home#331
Open
garacil wants to merge 1 commit into
Open
nua: parse inbound multipart bodies into the request home, not the handle home#331garacil wants to merge 1 commit into
garacil wants to merge 1 commit into
Conversation
…ndle home nua_session_server_init() parsed an inbound multipart/mixed body with msg_multipart_parse(nua_handle_home(nh), ...) and duplicated the extracted Content-Type and SDP payload into nua_handle_home(nh) as well. msg_multipart_parse() moves the parsed fragments into the supplied home (su_home_move), so the parsed multipart lives until the handle is destroyed. Every multipart INVITE handled on a given handle therefore accumulates on the handle home - a leak for handles that process many requests (re-INVITEs, or INVITEs retried after a challenge). This matches the growth reported when flooding 407-rejected multipart INVITEs. The parsed content is consumed immediately (the SDP offer is extracted into the request and handed to the offer/answer engine) and is not referenced past the request message, so allocate it in the request message home (msg_home(sr->sr_request.msg)) instead. request->sip_multipart, request->sip_content_type and request->sip_payload->pl_data then share the per-request lifetime and are released with the request. sr->sr_request.msg is set from nta_incoming_getrequest() and destroyed in nua_server_request_destroy(), so this is the correct per-request home. No ABI change. Fixes freeswitch#100.
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.
nua_session_server_init()parsed an inboundmultipart/mixedbody withmsg_multipart_parse(nua_handle_home(nh), ...)and duplicated the extractedContent-Typeand SDP payload intonua_handle_home(nh)as well.msg_multipart_parse()moves the parsed fragments into the supplied home (su_home_move()), so the parsed multipart lives until the handle is destroyed. Every multipart INVITE handled on a given handle therefore accumulates on the handle home — a leak for handles that process many requests (re-INVITEs, or INVITEs retried after a challenge). This matches the growth reported when flooding 407-rejected multipart INVITEs.The parsed content is consumed immediately (the SDP offer is extracted into the request and handed to the offer/answer engine) and is not referenced past the request message. This allocates it in the request message home (
msg_home(sr->sr_request.msg)) instead, sorequest->sip_multipart,request->sip_content_typeandrequest->sip_payload->pl_datashare the per-request lifetime and are released with the request.sr->sr_request.msgis set fromnta_incoming_getrequest()and destroyed innua_server_request_destroy(), so this is the correct per-request home. No ABI change.Fixes #100.