summaryrefslogtreecommitdiff
path: root/res
AgeCommit message (Collapse)Author
2017-09-28Merge "pjsip_message_filter: Fix regression causing bad contact address" into 14Jenkins2
2017-09-28Merge "res_rtp_asterisk.c: Fix bridge_p2p_rtp_write() reentrancy potential." ↵Jenkins2
into 14
2017-09-27res_pjsip_outbound_publish.c: Fix misplaced parenthesis.Richard Mudgett
The pjsip_publishc_init() call was referenced with a misplaced parentheses. As a result, outbound publication messages went out with an expiration of 1 second. ASTERISK-27298 Change-Id: I93622eabc8ee83e7a22e98c107f921284c605a08
2017-09-26pjsip_message_filter: Fix regression causing bad contact addressGeorge Joseph
The "res_pjsip: Filter out non SIP(S) requests" commit moved the filtering of messages to pjproject's PJSIP_MOD_PRIORITY_TRANSPORT_LAYER in order to filter out incoming bad uri schemes as early as possible. Since the change affected outgoing messages as well and the TRANSPORT layer is the last to be run on outgoing messages, we were overwriting the setting of external_signaling_address (which is set earlier by res_pjsip_nat) with an internal address. * pjsip_message_filter now registers itself as a pjproject module twice. Once in the TSX layer for the outgoing messages (as it was originally), then a second time in the TRANSPORT layer for the incoming messages to catch the invalid uri schemes. ASTERISK-27295 Reported by: Sean Bright Change-Id: I2c90190c43370f8a9d1c4693a19fd65840689c8c
2017-09-26res_rtp_asterisk.c: Fix bridge_p2p_rtp_write() reentrancy potential.Richard Mudgett
The bridge_p2p_rtp_write() has potential reentrancy problems. * Accessing the bridged RTP members must be done with the instance1 lock held. The DTMF and asymmetric codec checks must be split to be done with the correct RTP instance struct locked. i.e., They must be done when working on the appropriate side of the point to point bridge. * Forcing the RTP mark bit was referencing the wrong side of the point to point bridge. The set mark bit is used everywhere else to set the mark bit when sending not receiving. The patches for ASTERISK_26745 and ASTERISK_27158 did not take into account that not everything carried by RTP uses a codec. The telephony DTMF events are not exchanged with a codec. As a result when RFC2833/RFC4733 sent digits you would crash if "core set debug 1" is enabled, the DTMF digits would always get passed to the core even though the local native RTP bridge is active, and the DTMF digits would go out using the wrong SSRC id. * Add protection for non-format payload types like DTMF when updating the lastrxformat and lasttxformat. Also protect against non-format payload types when checking for asymmetric codecs. ASTERISK-27292 Change-Id: I6344ab7de21e26f84503c4d1fca1a41579364186
2017-09-22res_pjsip: Use ast_sip_is_content_type() where appropriateSean Bright
Change-Id: If3ab0d73d79ac4623308bd48508af2bfd554937d
2017-09-22Merge "res_config_pgsql: Fix removed support to previous for versions ↵Joshua Colp
PostgreSQL 9.1" into 14
2017-09-21Merge "res_srtp: lower log level of auth failures" into 14Jenkins2
2017-09-21res_config_pgsql: Fix removed support to previous for versions PostgreSQL 9.1Rodrigo Ramírez Norambuena
In PostgreSQL 9.1 the backslash are string literals and not the escape of characters. In previous issue ASTERISK_26057 was fixed the use of escape LIKE but the support for old version of Postgresql than 9.1 was dropped. The sentence before make was "ESCAPE '\'" but in version before than 9.1 need it to be as follow "ESCAPE '\\'". ASTERISK-27283 Change-Id: I96d9ee1ed7693ab17503cb36a9cd72847165f949
2017-09-19res_pjsip_pubsub: Check for Content-Type header in rx_notify_requestGeorge Joseph
pubsub_on_rx_notify_request wasn't checking for a null Content-Type header before checking that it was application/simple-message-summary. ASTERISK-27279 Reported by: Ross Beer Change-Id: Iec2a6c4d2e74af37ff779ecc9fd35644c5c4ea52
2017-09-19Merge "AST-2017-008: Improve RTP and RTCP packet processing." into 14Joshua Colp
2017-09-19Merge "res_calendar: On reload, update all configuration" into 14Joshua Colp
2017-09-18res_srtp: lower log level of auth failuresAlexander Traud
Previously, sRTP authentication failures were reported on log level WARNING. When such failures happen, each RT(C)P packet is affected, spamming the log. Now, those failures are reported at log level VERBOSE 2. Furthermore, the amount is further reduced (previously all two seconds, now all three seconds). Additionally, the new log entry informs whether media (RTP) or statistics (RTCP) are affected. ASTERISK-16898 #close Change-Id: I6c98d46b711f56e08655abeb01c951ab8e8d7fa0
2017-09-15AST-2017-008: Improve RTP and RTCP packet processing.Richard Mudgett
Validate RTCP packets before processing them. * Validate that the received packet is of a minimum length and apply the RFC3550 RTCP packet validation checks. * Fixed potentially reading garbage beyond the received RTCP record data. * Fixed rtp->themssrc only being set once when the remote could change the SSRC. We would effectively stop handling the RTCP statistic records. * Fixed rtp->themssrc to not treat a zero value as special by adding rtp->themssrc_valid to indicate if rtp->themssrc is available. ASTERISK-27274 Make strict RTP learning more flexible. Direct media can cause strict RTP to attempt to learn a remote address again before it has had a chance to learn the remote address the first time. Because of the rapid relearn requests, strict RTP could latch onto the first remote address and fail to latch onto the direct media remote address. As a result, you have one way audio until the call is placed on and off hold. The new algorithm learns remote addresses for a set time (1.5 seconds) before locking the remote address. In addition, we must see a configured number of remote packets from the same address in a row before switching. * Fixed strict RTP learning from always accepting the first new address packet as the new stream. * Fixed strict RTP to initialize the expected sequence number with the last received sequence number instead of the last transmitted sequence number. * Fixed the predicted next sequence number calculation in rtp_learning_rtp_seq_update() to handle overflow. ASTERISK-27252 Change-Id: Ia2d3aa6e0f22906c25971e74f10027d96525f31c
2017-09-15Merge "res_pjsip: Filter out non SIP(S) requests" into 14Jenkins2
2017-09-15res_calendar: On reload, update all configurationSean Bright
This changes the behavior of res_calendar to drop all existing calendars and re-create them whenever a reload is done. The Calendar API provides no way for configuration information to be pushed down to calendar 'techs' so updated settings would not take affect until a module unload/load was done or Asterisk was restarted. Asterisk 15+ already has a configuration option 'fetch_again_at_reload' that performs a similar function. Also fix a tiny memory leak in res_calendar_caldav while we're at it. ASTERISK-25524 #close Reported by: Jesper Change-Id: Ib0f8057642e9d471960f1a79fd42e5a3ce587d3b
2017-09-15Merge "res_calendar: Various fixes" into 14Jenkins2
2017-09-14res_pjsip: Filter out non SIP(S) requestsGeorge Joseph
Incoming requests with non sip(s) URIs in the Request, To, From or Contact URIs are now rejected with PJSIP_SC_UNSUPPORTED_URI_SCHEME (416). This is performed in pjsip_message_filter (formerly pjsip_message_ip_updater) and is done at pjproject's "TRANSPORT" layer before a request can even reach the distributor. URIs read by res_pjsip_outbound_publish from pjsip.conf are now also checked for both length and sip(s) scheme. Those URIs read by outbound registration and aor were already being checked for scheme but their error messages needed to be updated to include scheme failure as well as length failure. Change-Id: Ibb2f9f1d2dc7549da562af4cbd9156c44ffdd460
2017-09-13res_calendar: Various fixesSean Bright
* The way that we were looking at XML elements for CalDAV was extremely fragile, so use SAX2 for increased robustness. * Don't complain about a 'channel' not be specified if autoreminder is not set. Assume that if 'channel' is not set, we don't want to be notified. * Fix some truncated CLI output in 'calendar show calendar' and make the 'Autoreminder' description a bit more clear ASTERISK-24588 #close Reported by: Stefan Gofferje ASTERISK-25523 #close Reported by: Jesper Change-Id: I200d11afca6a47e7d97888f286977e2e69874b2c
2017-09-13res_pjsip: Add handling for incoming unsolicited MWI NOTIFYGeorge Joseph
A new endpoint parameter "incoming_mwi_mailbox" allows Asterisk to receive unsolicited MWI NOTIFY requests and make them available to other modules via the stasis message bus. res_pjsip_pubsub has a new handler "pubsub_on_rx_mwi_notify_request" that parses a simple-message-summary body and, if endpoint->incoming_mwi_account is set, calls ast_publish_mwi_state with the voice-message counts from the message. Change-Id: I08bae3d16e77af48fcccc2c936acce8fc0ef0f3c
2017-09-11res_rtp_asterisk.c: Add doxygen to RTCP payload types.Richard Mudgett
Change-Id: I3f20ce428777cc4ce9c13b2f808d29ff8c873998
2017-09-10res/res_pjsip: Fix localnet checks in pjsip, part 2.Walter Doekes
In 45744fc53, I mistakenly broke SDP media address rewriting by misinterpreting which address was checked in the localnet comparison. Instead of checking the remote peer address to decide whether we need media address rewriting, we check our local media address: if it's local, then we rewrite. This feels awkward, but works and even made directmedia work properly if you set local_net. (For the record: for local peers, the SDP media rewrite code is not called, so the comparison does no harm there.) ASTERISK-27248 #close Change-Id: I566be1c33f4d0a689567d451ed46bab9c3861d4f
2017-09-07Merge "res_srtp: Add support for libsrtp2.1." into 14Jenkins2
2017-09-07Merge "stasis/control.c: Fix set_interval_hook() ref leak." into 14Jenkins2
2017-09-06stasis/control.c: Fix set_interval_hook() ref leak.Richard Mudgett
Change-Id: Ia0edb7dc0dbbb879c079ff7000f1b722d86ce7dc
2017-09-06stasis/control: Fix possible deadlock with swap channelGeorge Joseph
If an error occurs during a bridge impart it's possible that the "bridge_after" callback might try to run before control_swap_channel_in_bridge has been signalled to continue. Since control_swap_channel_in_bridge is holding the control lock and the callback needs it, a deadlock will occur. * control_swap_channel_in_bridge now only holds the control lock while it's actually modifying the control structure and releases it while the bridge impart is running. * bridge_after_cb is now tolerant of impart failures. Change-Id: Ifd239aa93955b3eb475521f61e284fcb0da2c3b3
2017-09-06Merge "res/res_pjsip: Standardize/fix localnet checks across pjsip." into 14Jenkins2
2017-09-06Merge "res_rtp_asterisk.c: Check RTP packet version earlier." into 14Jenkins2
2017-09-06res_srtp: Add support for libsrtp2.1.Alexander Traud
Asterisk is able to use libSRTP 2.0.x. However since libSRTP 2.1.x, the macro SRTP_AES_ICM got renamed to SRTP_AES_ICM_128. Beside to still compile with previous versions of libSRTP, this change allows libSRTP 2.1.x as well. ASTERISK-27253 #close Change-Id: I2e6eb3c3bc844fee8a624060a2eb6f182dc70315
2017-09-05res_rtp_asterisk.c: Check RTP packet version earlier.Richard Mudgett
Change-Id: Ic6493a7d79683f3e5845dff1cee49445fd5a0adf
2017-09-05res/res_pjsip: Standardize/fix localnet checks across pjsip.Walter Doekes
In 2dee95cc (ASTERISK-27024) and 776ffd77 (ASTERISK-26879) there was confusion about whether the transport_state->localnet ACL has ALLOW or DENY semantics. For the record: the localnet has DENY semantics, meaning that "not in the list" means ALLOW, and the local nets are in the list. Therefore, checks like this look wrong, but are right: /* See if where we are sending this request is local or not, and if not that we can get a Contact URI to modify */ if (ast_apply_ha(transport_state->localnet, &addr) != AST_SENSE_ALLOW) { ast_debug(5, "Request is being sent to local address, " "skipping NAT manipulation\n"); (In the list == localnet == DENY == skip NAT manipulation.) And conversely, other checks that looked right, were wrong. This change adds two macro's to reduce the confusion and uses those instead: ast_sip_transport_is_nonlocal(transport_state, addr) ast_sip_transport_is_local(transport_state, addr) ASTERISK-27248 #close Change-Id: Ie7767519eb5a822c4848e531a53c0fd054fae934
2017-09-05res_pjsip_t38: Make t38_reinvite_response_cb tolerant of NULL channelGeorge Joseph
t38_reinvite_response_cb can get called by res_pjsip_session's session_inv_on_tsx_state_changed in situations where session->channel is NULL. If it is, the ast_log warning segfaults because it tries to get the channel name from a NULL channel. * Check session->channel and print "unknown channel" when it's NULL. ASTERISK-27236 Reported by: Ross Beer Change-Id: I4326e288d36327f6c79ab52226d54905cdc87dc7
2017-08-31Merge "pjsip_message_ip_updater: Fix issue handling "tel" URIs" into 14Joshua Colp
2017-08-31Merge "res_rtp_asterisk: Only learn a new source in learn state." into 14Joshua Colp
2017-08-30pjsip_message_ip_updater: Fix issue handling "tel" URIsGeorge Joseph
sanitize_tdata was assuming all URIs were SIP URIs so when a non SIP uri was in the From, To or Contact headers, the unconditional cast of a non-pjsip_sip_uri structure to pjsip_sip_uri caused a segfault when trying to access uri->other_param. * Added PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri) checks before attempting to cast or use the returned uri. ASTERISK-27152 Reported-by: Ross Beer Change-Id: Id380df790e6622c8058a96035f8b8f4aa0b8551f
2017-08-30AST-2017-006: Fix app_minivm application MinivmNotify command injectionCorey Farrell
An admin can configure app_minivm with an externnotify program to be run when a voicemail is received. The app_minivm application MinivmNotify uses ast_safe_system() for this purpose which is vulnerable to command injection since the Caller-ID name and number values given to externnotify can come from an external untrusted source. * Add ast_safe_execvp() function. This gives modules the ability to run external commands with greater safety compared to ast_safe_system(). Specifically when some parameters are filled by untrusted sources the new function does not allow malicious input to break argument encoding. This may be of particular concern where CALLERID(name) or CALLERID(num) may be used as a parameter to a script run by ast_safe_system() which could potentially allow arbitrary command execution. * Changed app_minivm.c:run_externnotify() to use the new ast_safe_execvp() instead of ast_safe_system() to avoid command injection. * Document code injection potential from untrusted data sources for other shell commands that are under user control. ASTERISK-27103 Change-Id: I7552472247a84cde24e1358aaf64af160107aef1
2017-08-30res_rtp_asterisk: Only learn a new source in learn state.Joshua Colp
This change moves the logic which learns a new source address for RTP so it only occurs in the learning state. The learning state is entered on initial allocation of RTP or if we are told that the remote address for the media has changed. While in the learning state if we continue to receive media from the original source we restart the learning process. It is only once we receive a sufficient number of RTP packets from the new source that we will switch to it. Once this is done the closed state is entered where all packets that do not originate from the expected source are dropped. The learning process has also been improved to take into account the time between received packets so a flood of them while in the learning state does not cause media to be switched. Finally RTCP now drops packets which are not for the learned SSRC if strict RTP is enabled. ASTERISK-27013 Change-Id: I56a96e993700906355e79bc880ad9d4ad3ab129c
2017-08-25res/res_pjsip_session: allow SDP answer to be regeneratedTorrey Searle
If an SDP answer hasn't been sent yet, it's legal to change it. This is required for PJSIP_DTMF_MODE to work correctly, and can also have use in the future for updating codecs too. ASTERISK-27209 #close Change-Id: Idbbfb7cb3f72fbd96c94d10d93540f69bd51e7a1
2017-08-24res_smdi: Clean up memory leakSean Bright
Change-Id: I1e33290929e1aa7c5b9cb513f8254f2884974de8
2017-08-22Merge "res_xmpp: fix inverted return code check in OAuth" into 14Jenkins2
2017-08-22res_xmpp: fix inverted return code check in OAuthMichael Kuron
fetch_access_token calls func_curl via ast_func_read. The latter returns 0 upon success and -1 if the function is not available. This commit inverts the return code check so that an error is printed if the module is not loaded and not if it is loaded. ASTERISK-27207 #close Change-Id: I9ef903f80702d1218e8701f65a4e5e918e6548fb
2017-08-17res_calendar_icalendar: Properly handle recurring eventsSean Bright
When looking for recurring events, use the correct end time based on the configured 'timeframe.' ASTERISK-27174 #close Reported by: Mark Thompson Change-Id: Id90c3cfc79d561a5521d79be176683e225f2edef
2017-08-15res_pjsip: Fix prune_on_boot to remove only contacts for the host.Richard Mudgett
* Check that the contact's reg_server matches the host's name before deleting any prune_on_boot contacts. We don't want to delete reliable transport contacts made with other servers if the ps_contacts database table is shared with other servers. Thanks to Ross Beer for pointing out that the original prune logic would delete reliable transport contacts from other servers. ASTERISK-27147 Change-Id: I8e439d0d1c266ffdfd7b73d1e5e466180a689bd0
2017-08-15res_xmpp: Google OAuth 2.0 protocol support for XMPP / MotifAndrey Egorov
Add ability to use tokens instead of passwords according to Google OAuth 2.0 protocol. ASTERISK-27169 Reported by: Andrey Egorov Tested by: Andrey Egorov Change-Id: I07f7052a502457ab55010a4d3686653b60f4c8db
2017-08-10res_pjsip_outbound_registration.c: Re-REGISTER on transport shutdown.Richard Mudgett
The fix for the issue is broken up into three parts. This is part three which handles the client side of REGISTER requests. The registered contact may no longer be valid on the server when the transport used is reliable and the connection is broken. * Re-REGISTER our contact if the reliable transport is broken after registration completes. We attempt to re-REGISTER immediately to minimize the time we are unreachable. Time may have already passed between the connection being broken and the loss being detected. * Reorder sip_outbound_registration_state_alloc() so the STATSD_GUAGE's are still correct if an allocation failure happens. ASTERISK-27147 Change-Id: I3668405b1ee75dfefb07c0d637826176f741ce83
2017-08-10res_pjsip: Remove ephemeral registered contacts on transport shutdown.Richard Mudgett
The fix for the issue is broken up into three parts. This is part two which handles the server side of REGISTER requests when rewrite_contact is enabled. Any registered reliable transport contact becomes invalid when the transport connection becomes disconnected. * Monitor the rewrite_contact's reliable transport REGISTER contact for shutdown. If it is shutdown then the contact must be removed because it is no longer valid. Otherwise, when the client attempts to re-REGISTER it may be blocked because the invalid contact is there. Also if we try to send a call to the endpoint using the invalid contact then the endpoint is not likely to see the request. The endpoint either won't be listening on that port for new connections or a NAT/firewall will block it. * Prune any rewrite_contact's registered reliable transport contacts on boot. The reliable transport no longer exists so the contact is invalid. * Websockets always rewrite the REGISTER contact address and the transport needs to be monitored for shutdown. * Made the websocket transport set a unique name since that is what we use as the ao2 container key. Otherwise, we would not know which transport we find when one of them shuts down. The names are also used for PJPROJECT debug logging. * Made the websocket transport post the PJSIP_TP_STATE_CONNECTED state event. Now the global keep_alive_interval option, initially idle shutdown timer, and the server REGISTER contact monitor can work on wetsocket transports. * Made the websocket transport set the PJSIP_TP_DIR_INCOMING direction. Now initially idle websockets will automatically shutdown. ASTERISK-27147 Change-Id: I397a5e7d18476830f7ffe1726adf9ee6c15964f4
2017-08-10res_pjsip: PJSIP Transport state monitor refactor.Richard Mudgett
The fix for the issue is broken up into three parts. This is part one which refactors the transport state monitor code to allow more modules to be able to monitor transports. * Pull the management of PJPROJECT's transport state callback code from res_pjsip_transport_management.c into res_pjsip. Now other modules can dynamically add and remove themselves from transport monitoring without worrying about breaking PJPROJECT's callback chain. * Add the ability for other modules to get a callback whenever a specific transport is shutdown. ASTERISK-27147 Change-Id: I7d9a31371eb1487c9b7050cf82a9af5180a57912
2017-08-10res_pjsip_transport_management.c: Rename some variables.Richard Mudgett
* Use monitored instead of the misleading keepalive name. Change-Id: I9e5bcbb4ab2b82d49bcd0f06dfe85d15e0b552b6
2017-08-10res_pjsip_messaging: IPv6 receive address needs bracketsScott Griepentrog
When handling an incoming SIP MESSAGE, PJSIP attaches the IP address that the message was received from to the message in the variable PJSIP_RECVADDR. When the IP address is IPv6 the :PORT appended results in an unparseable mess. By using an additional bit flag on the pj_sockaddr_print call, the conventional use of brackets around the address is achieved. ASTERISK-27193 #close Change-Id: I12342521f2ce87a5b6e4883d480a3fd957aa9fd9
2017-08-09Merge "res_rtp_asterisk: Make P2P bridge Asymmetric codec aware" into 14Joshua Colp