Skip to content
Snippets Groups Projects
  1. Dec 03, 2022
    • George Joseph's avatar
      pjsip_transport_events: Fix possible use after free on transport · 7684c9e9
      George Joseph authored
      It was possible for a module that registered for transport monitor
      events to pass in a pjsip_transport that had already been freed.
      This caused pjsip_transport_events to crash when looking up the
      monitor for the transport.  The fix is a two pronged approach.
      
      1. We now increment the reference count on pjsip_transports when we
      create monitors for them, then decrement the count when the
      transport is going to be destroyed.
      
      2. There are now APIs to register and unregister monitor callbacks
      by "transport key" which is a string concatenation of the remote ip
      address and port.  This way the module needing to monitor the
      transport doesn't have to hold on to the transport object itself to
      unregister.  It just has to save the transport_key.
      
      * Added the pjsip_transport reference increment and decrement.
      
      * Changed the internal transport monitor container key from the
        transport->obj_name (which may not be unique anyway) to the
        transport_key.
      
      * Added a helper macro AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR() that
        fills a buffer with the transport_key using a passed-in
        pjsip_transport.
      
      * Added the following functions:
        ast_sip_transport_monitor_register_key
        ast_sip_transport_monitor_register_replace_key
        ast_sip_transport_monitor_unregister_key
        and marked their non-key counterparts as deprecated.
      
      * Updated res_pjsip_pubsub and res_pjsip_outbound_register to use
        the new "key" monitor functions.
      
      NOTE: res_pjsip_registrar also uses the transport monitor
      functionality but doesn't have a persistent object other than
      contact to store a transport key.  At this time, it continues to
      use the non-key monitor functions.
      
      ASTERISK-30244
      
      Change-Id: I1a20baf2a8643c272dcf819871d6c395f148f00b
      7684c9e9
    • Mike Bradeen's avatar
      manager: prevent file access outside of config dir · 81f10e84
      Mike Bradeen authored
      Add live_dangerously flag to manager and use this flag to
      determine if a configuation file outside of AST_CONFIG_DIR
      should be read.
      
      ASTERISK-30176
      
      Change-Id: I46b26af4047433b49ae5c8a85cb8cda806a07404
      81f10e84
  2. Dec 01, 2022
  3. Nov 29, 2022
    • Naveen Albert's avatar
      pbx_builtins: Allow Answer to return immediately. · c7df5ee7
      Naveen Albert authored
      The Answer application currently waits for up to 500ms
      for media, even if users specify a different timeout.
      
      This adds an option to not wait for media on the channel
      by doing a raw answer instead. The default 500ms threshold
      is also documented.
      
      ASTERISK-30308 #close
      
      Change-Id: Id59cd340c44b8b8b2384c479e17e5123e917cba4
      c7df5ee7
    • Naveen Albert's avatar
      chan_dahdi: Allow FXO channels to start immediately. · 5ede4e21
      Naveen Albert authored
      Currently, chan_dahdi will wait for at least one
      ring before an incoming call can enter the dialplan.
      This is generally necessary in order to receive
      the Caller ID spill and/or distinctive ringing
      detection.
      
      However, if neither of these is required, then there
      is nothing gained by waiting for one ring and this
      unnecessarily delays call setup. Users can now
      use immediate=yes to make FXO channels (FXS signaled)
      begin processing dialplan as soon as Asterisk receives
      the call.
      
      ASTERISK-30305 #close
      
      Change-Id: I20818b370b2e4892c7f40c8a8753fa06a81750b5
      5ede4e21
    • Maximilian Fridrich's avatar
      core & res_pjsip: Improve topology change handling. · 60b81eab
      Maximilian Fridrich authored
      This PR contains two relatively separate changes in channel.c and
      res_pjsip_session.c which ensure that topology changes are not ignored
      in cases where they should be handled.
      
      For channel.c:
      
      The function ast_channel_request_stream_topology_change only triggers a
      stream topology request change indication, if the channel's topology
      does not equal the requested topology. However, a channel could be in a
      state where it is currently "negotiating" a new topology but hasn't
      updated it yet, so the topology request change would be lost. Channels
      need to be able to handle such situations internally and stream
      topology requests should therefore always be passed on.
      
      In the case of chan_pjsip for example, it queues a session refresh
      (re-INVITE) if it is currently in the middle of a transaction or has
      pending requests (among other reasons).
      
      Now, ast_channel_request_stream_topology_change always indicates a
      stream topology request change even if the requested topology equals the
      channel's topology.
      
      For res_pjsip_session.c:
      
      The function resolve_refresh_media_states does not process stream state
      changes if the delayed active state differs from the current active
      state. I.e. if the currently active stream state has changed between the
      time the sip session refresh request was queued and the time it is being
      processed, the session refresh is ignored. However, res_pjsip_session
      contains logic that ensures that session refreshes are queued and
      re-queued correctly if a session refresh is currently not possible. So
      this check is not necessary and led to some session refreshes being
      lost.
      
      Now, a session refresh is done even if the delayed active state differs
      from the current active state and it is checked whether the delayed
      pending state differs from the current active - because that means a
      refresh is necessary.
      
      Further, the unit test of resolve_refresh_media_states was adapted to
      reflect the new behavior. I.e. the changes to delayed pending are
      prioritized over the changes to current active because we want to
      preserve the original intention of the pending state.
      
      ASTERISK-30184
      
      Change-Id: Icd0703295271089057717006730b555b9a1d4e5a
      60b81eab
  4. Nov 28, 2022
    • Naveen Albert's avatar
      sla: Prevent deadlock and crash due to autoservicing. · 2efa290d
      Naveen Albert authored
      SLAStation currently autoservices the station channel before
      creating a thread to actually dial the trunk. This leads
      to duplicate servicing of the channel which causes assertions,
      deadlocks, crashes, and moreover not the correct behavior.
      
      Removing the autoservice prevents the crash, but if the station
      hangs up before the trunk answers, the call hangs since the hangup
      was never serviced on the channel.
      
      This is fixed by not autoservicing the channel, but instead
      servicing it in the thread dialing the trunk, since it is doing
      so synchronously to begin with. Instead of sleeping for 100ms
      in a loop, we simply use the channel for timing, and abort
      if it disappears.
      
      The same issue also occurs with SLATrunk when a call is answered,
      because ast_answer invokes ast_waitfor_nandfds. Thus, we use
      ast_raw_answer instead which does not cause any conflict and allows
      the call to be answered normally without thread blocking issues.
      
      ASTERISK-29998 #close
      
      Change-Id: Icc237d50354b5910000d2305901e86d2c87bb9d8
      2efa290d
  5. Nov 21, 2022
    • Jaco Kroon's avatar
      Build system: Avoid executable stack. · ce2153fc
      Jaco Kroon authored
      
      Found in res_geolocation, but I believe others may have similar issues,
      thus not linking to a specific issue.
      
      Essentially gcc doesn't mark the stack for being non-executable unless
      it's compiling the source, this informs ld via gcc to mark the object as
      not requiring an executable stack (which a binary blob obviously
      doesn't).
      
      ASTERISK-30321
      
      Change-Id: I71bcc2fd1fe0c82a28b3257405d6f2b566fd9bfc
      Signed-off-by: default avatarJaco Kroon <jaco@uls.co.za>
      ce2153fc
    • Naveen Albert's avatar
      func_json: Fix memory leak. · 002afc3f
      Naveen Albert authored
      A memory leak was present in func_json due to
      using ast_json_free, which just calls ast_free,
      as opposed to recursively freeing the JSON
      object as needed. This is now fixed to use the
      right free functions.
      
      ASTERISK-30293 #close
      
      Change-Id: I982324dde841dc9147c8d8ad35c8719daf418b49
      002afc3f
    • Naveen Albert's avatar
      test_json: Remove duplicated static function. · 1e77b8c4
      Naveen Albert authored
      Removes the function mkstemp_file and uses
      ast_file_mkftemp from file.h instead.
      
      ASTERISK-30295 #close
      
      Change-Id: I7412ec06f88c39ee353bcdb8c976c2fcac546609
      1e77b8c4
  6. Nov 16, 2022
    • Joshua C. Colp's avatar
      res_agi: Respect "transmit_silence" option for "RECORD FILE". · 61922d29
      Joshua C. Colp authored
      The "RECORD FILE" command in res_agi has its own
      implementation for actually doing the recording. This
      has resulted in it not actually obeying the option
      "transmit_silence" when recording.
      
      This change causes it to now send silence if the
      option is enabled.
      
      ASTERISK-30314
      
      Change-Id: Ib3a85601ff35d1b904f836691bad8a4b7e957174
      61922d29
  7. Nov 08, 2022
    • Naveen Albert's avatar
      app_mixmonitor: Add option to delete files on exit. · 6e59b01e
      Naveen Albert authored
      Adds an option that allows MixMonitor to delete
      its copy of any recording files before exiting.
      
      This can be handy in conjunction with options
      like m, which copy the file elsewhere, and the
      original files may no longer be needed.
      
      ASTERISK-30284 #close
      
      Change-Id: Ida093679c67e300efc154a97b6d8ec0f104e581e
      6e59b01e
    • Naveen Albert's avatar
      manager: Update ModuleCheck documentation. · 49cfdbbd
      Naveen Albert authored
      The ModuleCheck XML documentation falsely
      claims that the module's version number is returned.
      This has not been the case since 14, since the version
      number is not available anymore, but the documentation
      was not changed at the time. It is now updated to
      reflect this.
      
      ASTERISK-30285 #close
      
      Change-Id: Idde2d1205a11f2623fa1ddab192faa3dc4081e91
      49cfdbbd
  8. Nov 06, 2022
  9. Nov 02, 2022
    • George Joseph's avatar
      runUnittests.sh: Save coredumps to proper directory · 0c1c623d
      George Joseph authored
      Fixed the specification of "outputdir" when calling ast_coredumper
      so the txt files are saved in the correct place.
      
      ASTERISK-30282
      
      Change-Id: Ic631cb90c1e4c29d970c982dff45fda5e0eb15b6
      0c1c623d
    • Naveen Albert's avatar
      app_stack: Print proper exit location for PBXless channels. · dfe2f386
      Naveen Albert authored
      When gosub is executed on channels without a PBX, the context,
      extension, and priority are initialized to the channel driver's
      default location for that endpoint. As a result, the last Return
      will restore this location and the Gosub logs will print out bogus
      information about our exit point.
      
      To fix this, on channels that don't have a PBX, the execution
      location is left intact on the last return if there are no
      further stack frames left. This allows the correct location
      to be printed out to the user, rather than the bogus default
      context.
      
      ASTERISK-30076 #close
      
      Change-Id: I1d42a99c9aa9e3708d32718863175158a894e414
      dfe2f386
    • George Joseph's avatar
      chan_rtp: Make usage of ast_rtp_instance_get_local_address clearer · f723b465
      George Joseph authored
      unicast_rtp_request() was setting the channel variables like this:
      
      pbx_builtin_setvar_helper(chan, "UNICASTRTP_LOCAL_ADDRESS",
          ast_sockaddr_stringify_addr(&local_address));
      ast_rtp_instance_get_local_address(instance, &local_address);
      pbx_builtin_setvar_helper(chan, "UNICASTRTP_LOCAL_PORT",
          ast_sockaddr_stringify_port(&local_address));
      
      ...which made it appear that UNICASTRTP_LOCAL_ADDRESS was being
      set before local_address was set.  In fact, the address part of
      local_address was set earlier in the function, just not the port.
      This was confusing however so ast_rtp_instance_get_local_address()
      is now being called before setting UNICASTRTP_LOCAL_ADDRESS.
      
      ASTERISK-30281
      
      Change-Id: I872ac49477100f4eb33891d46efc6ca21ec81aa4
      f723b465
  10. Oct 31, 2022
    • Mike Bradeen's avatar
      res_pjsip: prevent crash on websocket disconnect · 50e2921a
      Mike Bradeen authored
      When a websocket (or potentially any stateful connection) is quickly
      created then destroyed, it is possible that the qualify thread will
      destroy the transaction before the initialzing thread is finished
      with it.
      
      Depending on the timing, this can cause an assertion within pjsip.
      
      To prevent this, ast_send_stateful_response will now create the group
      lock and add a reference to it before creating the transaction.
      
      While this should resolve the crash, there is still the potential that
      the contact will not be cleaned up properly, see:ASTERISK~29286. As a
      result, the contact has to 'time out' before it will be removed.
      
      ASTERISK-28689
      
      Change-Id: Id050fded2247a04d8f0fc5b8a2cf3e5482cb8cee
      50e2921a
    • Naveen Albert's avatar
      tcptls: Prevent crash when freeing OpenSSL errors. · afd86b47
      Naveen Albert authored
      write_openssl_error_to_log has been erroneously
      using ast_free instead of free, which will
      cause a crash when MALLOC_DEBUG is enabled since
      the memory was not allocated by Asterisk's memory
      manager. This changes it to use the actual free
      function directly to avoid this.
      
      ASTERISK-30278 #close
      
      Change-Id: Iac8b6468b718075809c45d8ad16b101af21a474d
      afd86b47
  11. Oct 28, 2022
    • Igor Goncharovsky's avatar
      res_pjsip_outbound_registration: Allow to use multiple proxies for registration · 096529d3
      Igor Goncharovsky authored
      Current registration code use pjsip_parse_uri to verify outbound_proxy
      that is different from the reading this option for the endpoint. This
      made value with multiple proxies invalid for registration pjsip settings.
      Removing URI validation helps to use registration through multiple proxies.
      
      ASTERISK-30217 #close
      
      Change-Id: I064558e66f04b9f3260c46181812a01349761357
      096529d3
  12. Oct 27, 2022
    • Naveen Albert's avatar
      tests: Fix compilation errors on 32-bit. · ca8900b0
      Naveen Albert authored
      Fix compilation errors caused by using size_t
      instead of uintmax_t and non-portable format
      specifiers.
      
      ASTERISK-30273 #close
      
      Change-Id: I363e6057ef84d54b88af80d23ad6147eef9216ee
      ca8900b0
    • Henning Westerholt's avatar
      res_pjsip: return all codecs on a re-INVITE without SDP · 12445040
      Henning Westerholt authored
      Currently chan_pjsip on receiving a re-INVITE without SDP will only
      return the codecs that are previously negotiated and not offering
      all enabled codecs.
      
      This causes interoperability issues with different equipment (e.g.
      from Cisco) for some of our customers and probably also in other
      scenarios involving 3PCC infrastructure.
      
      According to RFC 3261, section 14.2 we SHOULD return all codecs
      on a re-INVITE without SDP
      
      The PR proposes a new parameter to configure this behaviour:
      all_codecs_on_empty_reinvite. It includes the code, documentation,
      alembic migrations, CHANGES file and example configuration additions.
      
      ASTERISK-30193 #close
      
      Change-Id: I69763708d5039d512f391e296ee8a4d43a1e2148
      12445040
    • Naveen Albert's avatar
      res_pjsip_notify: Add option support for AMI. · 40b52322
      Naveen Albert authored
      The PJSIP notify CLI commands allow for using
      "options" configured in pjsip_notify.conf.
      
      This allows these same options to be used in
      AMI actions as well.
      
      Additionally, as part of this improvement,
      some repetitive common code is refactored.
      
      ASTERISK-30263 #close
      
      Change-Id: Ie4496b322b63b61eaf9672183a959ab99a04b6b5
      40b52322
    • Naveen Albert's avatar
      res_pjsip_logger: Add method-based logging option. · c32b39d1
      Naveen Albert authored
      
      Expands the pjsip logger to support the ability to filter
      by SIP message method. This can make certain types of SIP debugging
      easier by only logging messages of particular method(s).
      
      ASTERISK-30146 #close
      
      Co-authored-by: default avatarSean Bright <sean@seanbright.com>
      Change-Id: I9c8cbb6fc8686ef21190eb42e08bc9a9b147707f
      c32b39d1
    • Frederic LE FOLL's avatar
      Dialing API: Cancel a running async thread, may not cancel all calls · 50a44957
      Frederic LE FOLL authored
      race condition: ast_dial_join() may not cancel outgoing call, if
      function is called just after called party answer and before
      application execution (bit is_running_app not yet set).
      
      This fix adds ast_softhangup() calls in addition to existing
      pthread_kill() when is_running_app is not set.
      
      ASTERISK-30258
      
      Change-Id: Idbdd5c15122159661aa8e996a42d5800083131e4
      50a44957
  13. Oct 26, 2022
    • Naveen Albert's avatar
      chan_dahdi: Fix unavailable channels returning busy. · 180ca325
      Naveen Albert authored
      This fixes dahdi_request to properly set the cause
      code to CONGESTION instead of BUSY if no channels
      were actually available.
      
      Currently, the cause is erroneously set to busy
      if the channel itself is found, regardless of its
      current state. However, if the channel is not available
      (e.g. T1 down, card not operable, etc.), then the
      channel itself may not be in a functional state,
      in which case CHANUNAVAIL is the correct cause to use.
      
      This adds a simple check to ensure that busy tone
      is only returned if a channel is encountered that
      has an owner, since that is the only possible way
      that a channel could actually be busy.
      
      ASTERISK-30274 #close
      
      Change-Id: Iad5870223c081240c925b19df8d6af136953b994
      180ca325
    • Naveen Albert's avatar
      res_pjsip_pubsub: Prevent removing subscriptions. · 9258d821
      Naveen Albert authored
      pjproject does not provide any mechanism of removing
      event packages, which means that once a subscription
      handler is registered, it is effectively permanent.
      
      pjproject will assert if the same event package is
      ever registered again, so currently unloading and
      loading any Asterisk modules that use subscriptions
      will cause a crash that is beyond our control.
      
      For that reason, we now prevent users from being
      able to unload these modules, to prevent them
      from ever being loaded twice.
      
      ASTERISK-30264 #close
      
      Change-Id: I7fdcb1a5e44d38b7ba10c44259fe98f0ae9bc12c
      9258d821
    • Naveen Albert's avatar
      say: Don't prepend ampersand erroneously. · 407216a0
      Naveen Albert authored
      Some logic in say.c for determining if we need
      to also add an ampersand for file seperation was faulty,
      as non-successful files would increment the count, causing
      a leading ampersand to be added improperly.
      
      This is fixed, and a unit test that captures this regression
      is also added.
      
      ASTERISK-30248 #close
      
      Change-Id: I02c1d3a11d82fe4ea8b462070cbd1effb5834d2b
      407216a0
  14. Oct 14, 2022
  15. Oct 11, 2022
    • Mike Bradeen's avatar
      audiohook: add directional awareness · 907d7e7d
      Mike Bradeen authored
      Add enum to allow setting optional direction. If set to only one
      direction, only feed matching-direction frames to the associated
      slin factory.
      
      This prevents mangling the transcoder on non-mixed frames when the
      READ and WRITE frames would have otherwise required it.  Also
      removes the need to mute or discard the un-wanted frames as they
      are no longer added in the first place.
      
      res_stasis_snoop is changed to use this addition to set direction
      on audiohook based on spy direction.
      
      If no direction is set, the ast_audiohook_init will init this enum
      to BOTH which maintains existing functionality.
      
      ASTERISK-30252
      
      Change-Id: If8716bad334562a5d812be4eeb2a92e4f3be28eb
      907d7e7d
  16. Oct 10, 2022
    • Naveen Albert's avatar
      cdr: Allow bridging and dial state changes to be ignored. · b331caca
      Naveen Albert authored
      Allows bridging, parking, and dial messages to be globally
      ignored for all CDRs such that only a single CDR record
      is generated per channel.
      
      This is useful when CDRs should endure for the lifetime of
      an entire channel and bridging and dial updates in the
      dialplan should not result in multiple CDR records being
      created for the call. With the ignore bridging option,
      bridging changes have no impact on the channel's CDRs.
      With the ignore dial state option, multiple Dials and their
      outcomes have no impact on the channel's CDRs. The
      last disposition on the channel is preserved in the CDR,
      so the actual disposition of the call remains available.
      
      These two options can reduce the amount of "CDR hacks" that
      have hitherto been necessary to ensure that CDR was not
      "spoiled" by these messages if that was undesired, such as
      putting a dummy optimization-disabled local channel between
      the caller and the actual call and putting the CDR on the channel
      in the middle to ensure that CDR would persist for the entire
      call and properly record start, answer, and end times.
      Enabling these options is desirable when calls correspond
      to the entire lifetime of channels and the CDR should
      reflect that.
      
      Current default behavior remains unchanged.
      
      ASTERISK-30091 #close
      
      Change-Id: I393981af42732ec5ac3ff9266444abb453b7c832
      b331caca
    • Naveen Albert's avatar
      res_tonedetect: Add ringback support to TONE_DETECT. · e0e7f357
      Naveen Albert authored
      Adds support for detecting audible ringback tone
      to the TONE_DETECT function using the p option.
      
      ASTERISK-30254 #close
      
      Change-Id: Ie2329ff245248768367d26749c285fbe823f6414
      e0e7f357
    • Naveen Albert's avatar
      chan_dahdi: Resolve format truncation warning. · 98fc05f1
      Naveen Albert authored
      Fixes a format truncation warning in notify_message.
      
      ASTERISK-30256 #close
      
      Change-Id: I983a423c0214641ca4f8c9dfe0b19c47448fdee1
      98fc05f1
    • Philip Prindeville's avatar
      res_crypto: don't modify fname in try_load_key() · ef74ecac
      Philip Prindeville authored
      "fname" is passed in as a const char *, but strstr() mangles that
      into a char *, and we were attempting to modify the string in place.
      This is an unwanted (and undocumented) side-effect.
      
      ASTERISK-30213
      
      Change-Id: Ifa36d352aafeb7f9beec3f746332865c7d21e629
      ef74ecac
    • Philip Prindeville's avatar
      res_crypto: use ast_file_read_dirs() to iterate · 5e2485b5
      Philip Prindeville authored
      ASTERISK-30213
      
      Change-Id: I115f5f8942ffcfb23cd2559a55bac8a2eba081e0
      5e2485b5
    • George Joseph's avatar
      res_geolocation: Update wiki documentation · 2a500b32
      George Joseph authored
      Also added a note to the geolocation.conf.sample file
      and added a README to the res/res_geolocation/wiki
      directory.
      
      Change-Id: I89c3c5db8c0701b33127993622d5e4f904bddfbc
      2a500b32
  17. Sep 29, 2022
    • Maximilian Fridrich's avatar
      res_pjsip: Add mediasec capabilities. · 0d2e1401
      Maximilian Fridrich authored
      This patch adds support for mediasec SIP headers and SDP attributes.
      These are defined in RFC 3329, 3GPP TS 24.229 and
      draft-dawes-sipcore-mediasec-parameter. The new features are
      implemented so that a backbone for RFC 3329 is present to streamline
      future work on RFC 3329.
      
      With this patch, Asterisk can communicate with Deutsche Telekom trunks
      which require these fields.
      
      ASTERISK-30032
      
      Change-Id: Ia7f5b5ba42db18074fdd5428c4e1838728586be2
      0d2e1401
  18. Sep 28, 2022
  19. Sep 27, 2022
    • Holger Hans Peter Freyther's avatar
      res_prometheus: Do not crash on invisible bridges · 62881c66
      Holger Hans Peter Freyther authored
      Avoid crashing by skipping invisible bridges and checking the
      snapshot for a null pointer. In effect this is how the bridges
      are enumerated in res/ari/resource_bridges.c already.
      
      ASTERISK-30239
      ASTERISK-30237
      
      Change-Id: I58ef9f44036feded5966b5fc70ae754f8182883d
      62881c66
  20. Sep 26, 2022
    • Naveen Albert's avatar
      res_pjsip_geolocation: Change some notices to debugs. · 8afb313a
      Naveen Albert authored
      If geolocation is not in use for an endpoint, the NOTICE
      log level is currently spammed with messages about this,
      even though nothing is wrong and these messages provide
      no real value. These log messages are therefore changed
      to debugs.
      
      ASTERISK-30241 #close
      
      Change-Id: I656b355d812f67cc0f0fdf09b00b0e1458598bb4
      8afb313a
Loading