Skip to content
Snippets Groups Projects
  1. Mar 21, 2017
    • Sean Bright's avatar
      res_pjsip_messaging: Check URI type before dereferencing · 6b4b8778
      Sean Bright authored
      We aren't validating that the URI we just parsed is a SIP/SIPS one before
      trying to access the user, host, and port members of a possibly uninitialized
      structure.
      
      Also update the MessageSend documentation to indicate what 'from' formats are
      accepted.
      
      ASTERISK-26484 #close
      Reported by: Vinod Dharashive
      
      Change-Id: I476b5cc5f18a7713d0ee945374f2a1c164857d30
      6b4b8778
  2. Mar 20, 2017
    • Sean Bright's avatar
      thread safety: Don't use getprotobyname() · fc71c18a
      Sean Bright authored
      POSIX does not require getprotobyname() to be thread safe and some
      implementations use static memory which causes issues when multiple
      threads are used.
      
      Further, our usage of it today is just to ultimately get IPPROTO_TCP
      for calls to setsockopt(). So instead we just use IPPROTO_TCP directly.
      
      Change-Id: I2e14e58674808f7ce99b2f5e900d0f90d0d8da48
      fc71c18a
  3. Mar 15, 2017
    • Richard Mudgett's avatar
      autochan/mixmonitor/chanspy: Fix unsafe channel locking and references. · c87e7dd9
      Richard Mudgett authored
      Dereferencing struct ast_autochan.chan without first calling
      ast_autochan_channel_lock() is unsafe because the pointer could change at
      any time due to a masquerade.  Unfortunately, ast_autochan_channel_lock()
      itself uses struct ast_autochan.chan unsafely and can result in a deadlock
      if the original channel happens to get destroyed after a masquerade in
      addition to the pointer getting changed.
      
      The problem is more likely to happen with v11 and earlier because
      masquerades are used to optimize out local channels on those versions.
      However, it could still happen on newer versions if the channel is
      executing a dialplan application when the channel is transferred or
      redirected.  In this situation a masquerade still must be used.
      
      * Added a lock to struct ast_autochan to safely be able to use
      ast_autochan.chan while trying to get the channel lock in
      ast_autochan_channel_lock().  The locking order is the channel lock then
      the autochan lock.  Locking in the other direction requires deadlock
      avoidance.
      
      * Fix unsafe ast_autochan.chan usages in app_mixmonitor.c.
      
      * Fix unsafe ast_autochan.chan usages in app_chanspy.c.
      
      * app_chanspy.c: Removed unused autochan parameter from next_channel().
      
      ASTERISK-26867
      
      Change-Id: Id29dd22bc0f369b44e23ca423d2f3657187cc592
      c87e7dd9
  4. Mar 14, 2017
    • Richard Mudgett's avatar
      pbx.c: Fix crash from malformed exten pattern. · f9970908
      Richard Mudgett authored
      Forgetting to indicate an exten is a pattern can cause a crash if the
      "pattern" has a character set range.  e.g., "9999[3-5]" The crash is due
      to a buffer overwrite because the '-' exten eye-candy wasn't removed as
      expected and overran the allocated space.
      
      The buffer overwrite is fixed two ways in this patch.
      
      1) Fix ext_strncpy() to distinguish between pattern and non-pattern
      extens.  Now '-' characters are removed when they are eye-candy and not
      when they are part of a pattern character set.  Since the function is
      private to pbx.c, the return value now returns the number of bytes written
      to the destination buffer instead of the strlen() of the final buffer so
      the callers that care don't need to add one.
      
      2) Fix callers to ext_strncpy() to supply the correct available buffer
      size of the destination buffer.
      
      ASTERISK-26668
      
      Change-Id: I555d97411140e47e0522684062d174fbe32aa84a
      f9970908
    • George Joseph's avatar
      RFC sdp: Initial SDP creation · 8470c2bd
      George Joseph authored
      * Added additional fields to ast_sdp_options.
      * Re-organized ast_sdp.
      * Updated field names to correspond to RFC4566 terminology.
      * Created allocs/frees for SDP children.
      * Created getters/setters for SDP children where appropriate.
      * Added ast_sdp_create_from_state.
      * Refactored res_sdp_translator_pjmedia for changes.
      
      Change-Id: Iefbd877af7f5a4d3c74deead1bff8802661b0d48
      8470c2bd
    • Matt Jordan's avatar
      main/stasis_cache: Demote the ERROR message when removing a nonexistent item · b03b7271
      Matt Jordan authored
      This patch demotes the ERROR message that is displayed when a
      nonexistent item is removed from the Stasis cache. The genesis of this
      demotion is due to chan_sip's realtime peers and their interaction with
      Asterisk's core ast_endpoint code, but ostensibly it could happen from
      other channel drivers as well.
      
      Since Mark Michelson already did an excellent job of explaining on this
      issue, it is quoted here for posterity:
      
      "Internally, when a realtime peer is retrieved, Asterisk creates an
      ast_endpoint structure. When that peer is destroyed, the ast_endpoint is
      destroyed as well. Part of the destruction of the ast_endpoint involves
      clearing the Stasis cache of all information about that endpoint. The
      problem here is that the act of creating the ast_endpoint is not enough
      to actually put any information in the Stasis cache. Instead, something
      has to happen, such as a state change, in order for the Stasis cache to
      have any information about that endpoint. When a device registers,
      chan_sip creates an ast_endpoint structure, processes the REGISTER, and
      then destroys the ast_endpoint. When the ast_endpoint is destroyed,
      there is nothing to destroy in the Stasis cache, so an error message is
      emitted. When you use rtcachefriends, ast_endpoint structures persist
      for the lifetime of the module and so you do not see this error
      message."
      
      ASTERISK-25237 #close
      
      Change-Id: I53cebc6b4a897a1ab9564182b75c177780feff70
      b03b7271
  5. Mar 08, 2017
  6. Mar 07, 2017
    • Joshua Colp's avatar
      core: Add stream topology changing primitives with tests. · 3ed05bad
      Joshua Colp authored
      This change adds a few things to facilitate stream topology changing:
      
      1. Control frame types have been added for use by the channel driver
      to notify the application that the channel wants to change the stream
      topology or that a stream topology change has been accepted. They are
      also used by the indicate interface to the channel that the application
      uses to indicate it wants to do the same.
      
      2. Legacy behavior has been adopted in ast_read() such that if a
      channel requests a stream topology change it is denied automatically
      and the current stream topology is preserved if the application is
      not capable of handling streams.
      
      Tests have also been written which confirm the multistream and
      non-multistream behavior.
      
      ASTERISK-26839
      
      Change-Id: Ia68ef22bca8e8457265ca4f0f9de600cbcc10bc9
      3ed05bad
  7. Mar 06, 2017
  8. Mar 03, 2017
    • Richard Mudgett's avatar
      core: Cleanup ast_get_hint() usage. · c9296b23
      Richard Mudgett authored
      * manager.c:manager_state_cb() Fix potential use of uninitialized hint[]
      if a hint does not exist for the requested extension.  Ran into this when
      developing a testsuite test.  The AMI event ExtensionStatus came out with
      the hint header value containing garbage.  The AMI event PresenceStatus
      also had the same issue.
      
      * manager.c:action_extensionstate() no need to completely initialize the
      hint[].  Only initialize the first element.
      
      * pbx.c:ast_add_hint() Remove unnecessary assignment.
      
      * chan_sip.c: Eliminate an unneeded hint[] local variable.  We only care
      about the return value of ast_get_hint() there.
      
      Change-Id: Ia9a8786f01f93f1f917200f0a50bead0319af97b
      c9296b23
  9. Mar 01, 2017
    • George Joseph's avatar
      stream: Unit tests for stream read and tweaks framework · 0560c323
      George Joseph authored
      * Removed the AST_CHAN_TP_MULTISTREAM tech property.  We now rely
        on read_stream being set to indicate a multi stream channel.
      * Added ast_channel_is_multistream convenience function.
      * Fixed issue where stream and default_stream weren't being set on
        a frame retrieved from the queue.
      * Now testing for NULL being returned from the driver's read or
        read_stream callback.
      * Fixed issue where the dropnondefault code was crashing on a
        NULL f.
      * Now enforcing that if either read_stream or write_stream are
        set when ast_channel_tech_set is called that BOTH are set.
      * Added the unit tests.
      
      ASTERISK-26816
      
      Change-Id: If7792b20d782e71e823dabd3124572cf0a4caab2
      0560c323
    • Mark Michelson's avatar
      SDP: Add initial SDP state machine. · 9c55a717
      Mark Michelson authored
      This introduces and documents the various states in the state machine.
      This also introduces API functions that induce state changes, and places
      TODO comments telling what needs to be done in addition to what is
      already there. Those TODOs will be replaced with real code in upcoming
      changes.
      
      Change-Id: I871c0eb480b4c84d83e91ac5628e7a673e8b89ed
      9c55a717
  10. Feb 28, 2017
  11. Feb 27, 2017
    • George Joseph's avatar
      build: Warn if asterisk is installed in both 32 and 64 bit sys dirs · 4692a32e
      George Joseph authored
      ... and clean them both up on uninstall.
      
      We've fixed the issue where 'make install' was installing to
      /usr/lib on 64-bit systems that use /usr/lib64.  Now we need
      to clean up the remnants in /usr/lib.
      
      * 'make install' now prints a warning if DESTDIR/ASTLIBDIR
        contains 'lib64' and libasterisk* shared libraries or modules
        are also found in DESTDIR/ASTLIBDIR with 'lib64' transformed
        to 'lib'.
      
      * 'make uninstall' ALWAYS cleans up both DESTDIR/ASTLIBDIR and
        DESTDIR/ASTLIBDIR with 'lib64' transformed to 'lib'.
      
      ASTERISK-26705
      
      Change-Id: I6edddeb3c07a51e7c7ba7cac3c05e4bf3ec3f01f
      4692a32e
  12. Feb 24, 2017
    • Joshua Colp's avatar
      channel: Add ast_read_stream function for reading frames from all streams. · c07c6714
      Joshua Colp authored
      This change introduces an ast_read_stream function and callback in
      the channel technology which allows reading frames from all streams
      and not just the default streams.
      
      The stream number has also been added to frames. This is to allow the
      case where frames are queued onto the channel instead of being read
      directly from the driver.
      
      This change does impose a restriction on reading though: a chain of
      frames can only contain frames from the same stream.
      
      ASTERISK-26816
      
      Change-Id: I5d7dc35e86694df91fd025126f6cfe0453aa38ce
      c07c6714
  13. Feb 23, 2017
    • George Joseph's avatar
      build: Execute ldconfig to build cache. (take two) · b0067bcf
      George Joseph authored
      On some platforms a multiarch approach is used for libraries.
      The build system does not take this into account and still
      places libraries into the lib directory if no --libdir is
      specified to configure. On initial startup this results in
      libasteriskssl.so not being found, as it is not in the multiarch
      lib directory.  To make matters worse, options were being passed
      to ldconfig on both Linux and FreeBSD that actually prevented
      the rebuild of the cache.
      
       * Fedora has a /usr/share/config.site that automatically tells
         autoconf to use /usr/lib64 but CentOS does not. This logic was
         copied to configure.ac and modified so systems like Ubuntu,
         which still use /usr/lib for 64-bit systems, aren't affected.
      
      Now that we have them in the correct directory...
      
      In order for the system loader to find libasteriskssl and
      libasteriskpj, one of 3 things has to happen...
      
        - The linker cache must be rebuilt including the directory
          where the libasterisk* libraries were installed.  Only root
          can rebuild the cache.  This was busted.
        - We have to link the asterisk binary with an rpath pointing
          to the directrory where the libasterisk* libraries were
          installed.  This makes things very complicated and will happen
          over the collective dead bodies of everyone who's had to
          package a distribution with an rpath.
        - Finally, you can start asterisk with LD_LIBRARY_PATH set to the
          directrory where the libasterisk* libraries were installed.
      
      There are no other options. So...
      
       * The invokation of ldconfig has been moved from main/Makefile
         to ASTTOPDIR/Makefile, the options have been removed, and
         DESTDIR/ASTLIBDIR appended.  If you aren't root, you will be
         warned after the "Asterisk Installation Compete" banner that
         you must re-run 'make install' as root, manually run
         'ldconfig DESTDIR/ASTLIBDIR' as root, or run asterisk with
         LD_LIBRARY_PATH.
      
      ASTERISK-26705
      
      Change-Id: I2a64b7c33a7d3e9bde20f47e3d3ab771977af982
      b0067bcf
    • Joshua Colp's avatar
      channel: Add support for writing to a specific stream. · 6cc890b8
      Joshua Colp authored
      This change adds an ast_write_stream function which allows
      writing a frame to a specific media stream. It also moves
      ast_write() to using this underneath by writing media
      frames provided to it to the default streams of the channel.
      Existing functionality (such as audiohooks, framehooks, etc)
      are limited to being applied to the default stream only.
      
      Unit tests have also been added which test the behavior of
      both non-multistream and multistream channels to confirm that
      the write() and write_stream() callbacks are invoked
      appropriately.
      
      ASTERISK-26793
      
      Change-Id: I4df20d1b65bd4d787fce0b4b478e19d2dfea245c
      6cc890b8
    • frahaase's avatar
      Binaural synthesis (confbridge): Adds binaural synthesis to bridge_softmix. · 094c26aa
      frahaase authored
      Adds binaural synthesis to bridge_softmix (via convolution using libfftw3).
      Binaural synthesis is conducted at 48kHz.
      For a conference, only one spatial representation is rendered.
      The default rendering is applied for mono-capable channels.
      
      ASTERISK-26292
      
      Change-Id: Iecdb381b6adc17c961049658678f6219adae1ddf
      094c26aa
  14. Feb 22, 2017
  15. Feb 21, 2017
    • Mark Michelson's avatar
      Add initial SDP state code. · a738772e
      Mark Michelson authored
      This establishes the basic allocation/destruction of an SDP state
      object, plus some of the simpler getter methods involved. Subsequent
      tasks will deal with adding a state machine, creating SDPs from
      capabilities and options, and merging SDPs into a joint SDP.
      
      Change-Id: Ie3757ce186f04b65e9d1883f5aace53f24e53709
      a738772e
    • Joshua Colp's avatar
      build: Execute ldconfig to build cache. · 28c8e4f5
      Joshua Colp authored
      On some platforms a multiarch approach is used for libraries.
      The build system does not take this into account and still
      places libraries into the lib directory if no --libdir is
      specified to configure. On initial startup this results in
      libasteriskssl.so not being found, as it is not in the multiarch
      lib directory.
      
      This change does the minimally invasive thing and executes
      ldconfig so that the libraries in the lib directory are found
      and their location cached. By doing so Asterisk starts up fine.
      
      If DESTDIR is specified, however, the old logic is executed as
      the install process may not have permission to alter the ldconfig
      cache.
      
      ASTERISK-26705
      
      Change-Id: If4eca46ac510c6fea5568256280ffdb3888d7bb4
      28c8e4f5
  16. Feb 20, 2017
  17. Feb 17, 2017
    • Richard Mudgett's avatar
      tcptls.c: Add some missing allocation failure checks. · 0b427f9b
      Richard Mudgett authored
      * Fix tcptls_session ref and fd leak in ast_tcptls_server_root().
      
      Change-Id: I0ddf01cd3c10d3b6666d7bf68d4e206a37f4fbdb
      0b427f9b
    • Mark Michelson's avatar
      Remove extra ast_iostream_close() calls. · dbc35980
      Mark Michelson authored
      When AMI encounters an error at the beginning of a session, it would
      explicitly call ast_iostream_close() on its tcptls session's iostream.
      It then would jump to a label where it would shut down the tcptls
      session instance. The tcptls session instance would again attempt to
      close the iostream.
      
      Under normal circumstances, this might go by unnoticed. However, when
      MALLOC_DEBUG is enabled, all fields on the iostream get set to
      0xdeaddead when the iostream is freed. Thus a second call to
      ast_iostream_close() after the iostream has been freed would reslt in an
      attempt to call SSL_shutdown on 0xdeaddead, which would crash and burn
      horribly.
      
      The fix here is to not directly close the iostream from the dangerous
      scenarios. The specific scenarios are:
      * Exceeding the configured authlimit
      * Failing to build a mansession on a new connection
      
      Change-Id: I908f98d516afd5a263bd36b072221008a4731acd
      dbc35980
    • Mark Michelson's avatar
      Add SDP translator and PJMEDIA implementation. · 5a130b2e
      Mark Michelson authored
      This creates the following:
      * Asterisk's internal representation of an SDP
      * An API for translating SDPs from one format to another
      * An implementation of a translator for PJMEDIA
      
      Change-Id: Ie2ecd3cbebe76756577be9b133e84d2ee356d46b
      5a130b2e
    • Mark Michelson's avatar
      Add initial SDP options. · 8af63425
      Mark Michelson authored
      This is step one of adding an SDP API: defining some
      configurable settings for SDPs. This is based on options
      that are currently supported in Asterisk.
      
      Change-Id: I1ede91aafed403b12a9ccdfb91a88389baa7e5d7
      8af63425
  18. Feb 16, 2017
    • Joshua Colp's avatar
      build: Execute ldconfig to build cache. · 8851c3e0
      Joshua Colp authored
      On some platforms a multiarch approach is used for libraries.
      The build system does not take this into account and still
      places libraries into the lib directory if no --libdir is
      specified to configure. On initial startup this results in
      libasteriskssl.so not being found, as it is not in the multiarch
      lib directory.
      
      This change does the minimally invasive thing and executes
      ldconfig so that the libraries in the lib directory are found
      and their location cached. By doing so Asterisk starts up fine.
      
      ASTERISK-26705
      
      Change-Id: I6d30b6427e9d5e69470e11327c7ff203fa7da519
      8851c3e0
    • George Joseph's avatar
      stream: Rename creates/destroys to allocs/frees · f8f513d3
      George Joseph authored
      To be consistent with sdp implementation.
      
      Change-Id: I714e300939b4188f58ca66ce9d1e84b287009500
      f8f513d3
    • Joshua Elson's avatar
      http: Ensure capath is defined on all http creations · ac7a34c5
      Joshua Elson authored
      ASTERISK-26794 #close
      
      Change-Id: I9cbc3b6b6a8aab590f5ccde9c262a98e4d5253a1
      ac7a34c5
  19. Feb 14, 2017
  20. Feb 13, 2017
    • Joshua Colp's avatar
      stream: Add stream topology unit tests and fix uncovered bugs. · 6c4657e2
      Joshua Colp authored
      This change adds unit tests for the various API calls relating
      to stream topologies. This includes creation, destruction,
      inspection, and manipulation.
      
      Through this a few bugs were uncovered in the implementation:
      
      1. Creating a topology using a format capabilities would fail as
      the code considered a return value of 0 from the append stream
      function to indicate an error which is incorrect.
      
      2. Not all functions which placed a stream into a topology
      set the position on the stream itself.
      
      3. Appending a stream would cause a frack if the position
      provided was the last one. This occurred because the existing
      stream was queried but the index was outside of what the
      vector was currently at for size.
      
      ASTERISK-26786
      
      Change-Id: Id5590e87c8a605deea1a89e53169a9c011d66fa0
      6c4657e2
    • Sean Bright's avatar
      cli: Fix various CLI documentation and completion issues · 3f943737
      Sean Bright authored
      * app_minivm: Use built-in completion facilities to complete optional
      arguments.
      
      * app_voicemail: Use built-in completion facilities to complete
      optional arguments.
      
      * app_confbridge: Add missing colons after 'Usage' text.
      
      * chan_alsa: Use built-in completion facilities to complete optional
      arguments.
      
      * chan_sip: Use built-in completion facilities to complete optional
      arguments. Add completions for 'load' for 'sip show user', 'sip show
      peer', and 'sip qualify peer.'
      
      * chan_skinny: Correct and extend completions for 'skinny reset' and
      'skinny show line.'
      
      * func_odbc: Correct completions for 'odbc read' and 'odbc write'
      
      * main/astmm: Use built-in completion facilities to complete arguments
      for 'memory' commands.
      
      * main/bridge: Correct completions for 'bridge kick.'
      
      * main/ccss: Use built-in completion facilities to complete arguments
      for 'cc cancel' command.
      
      * main/cli: Add 'all' completion for 'channel request hangup.' Correct
      completions for 'core set debug channel.' Correct completions for 'core
      show calls.'
      
      * main/pbx_app: Remove redundant completions for 'core show
      applications.'
      
      * main/pbx_hangup_handler: Remove unused completions for 'core show
      hanguphandlers all.'
      
      * res_sorcery_memory_cache: Add completion for 'reload' argument of
      'sorcery memory cache stale' and properly implement.
      
      Change-Id: Iee58c7392f6fec34ad9d596109117af87697bbca
      3f943737
    • George Joseph's avatar
      stream: Add media stream topology definition and API · 8b72ec31
      George Joseph authored
      This change adds the media stream topology definition and API for
      accessing and using it.
      
      Some refactoring of the stream was also done.
      
      ASTERISK-26786
      
      Change-Id: Ic930232d24d5ad66dcabc14e9b359e0ff8e7f568
      8b72ec31
    • Joshua Colp's avatar
      channel: Protect flags in ast_waitfor_nandfds operation. · 89871576
      Joshua Colp authored
      The ast_waitfor_nandfds operation will manipulate the flags
      of channels passed in. This was previously done without
      the channel lock being held. This could result in incorrect
      values existing for the flags if another thread manipulated
      the flags at the same time.
      
      This change locks the channel during flag manipulation.
      
      ASTERISK-26788
      
      Change-Id: I2c5c8edec17c9bdad4a93291576838cb552ca5ed
      89871576
  21. Feb 10, 2017
    • Sean Bright's avatar
      manager: Restore Originate failure behavior from Asterisk 11 · 09107730
      Sean Bright authored
      In Asterisk 11, if the 'Originate' AMI command failed to connect the provided
      Channel while in extension mode, a 'failed' extension would be looked up and
      run. This was, I believe, unintentionally removed in 51b6c496. This patch
      restores that behavior.
      
      This also adds an enum for the various 'synchronous' modes in an attempt to
      make them meaningful.
      
      ASTERISK-26115 #close
      Reported by: Nasir Iqbal
      
      Change-Id: I8afbd06725e99610e02adb529137d4800c05345d
      09107730
    • Richard Mudgett's avatar
      core: Cleanup some channel snapshot staging anomalies. · 16fdb11b
      Richard Mudgett authored
      We shouldn't unlock the channel after starting a snapshot staging because
      another thread may interfere and do its own snapshot staging.
      
      * app_dial.c:dial_exec_full() made hold the channel lock while setting up
      the outgoing channel staging.  Made hold the channel lock after the called
      party answers while updating the caller channel staging.
      
      * chan_sip.c:sip_new() completed the channel staging on off-nominal exit.
      Also we need to use ast_hangup() instead of ast_channel_unref() at that
      location.
      
      * channel.c:__ast_channel_alloc_ap() added a comment about not needing to
      complete the channel snapshot staging on off-nominal exit paths.
      
      * rtp_engine.c:ast_rtp_instance_set_stats_vars() made hold the channel
      locks while staging the channels for the stats channel variables.
      
      Change-Id: Iefb6336893163f6447bad65568722ad5d5d8212a
      16fdb11b
    • Joshua Colp's avatar
      stream: Add media stream definition and API with unit tests. · bab4885f
      Joshua Colp authored
      This change adds the media stream definition and API for
      accessing and using it. Unit tests have also been written
      which exercise aspects of the API.
      
      ASTERISK-26773
      
      Change-Id: I3dbe54065b55aaa51f467e1a3bafd67fb48cac87
      bab4885f
  22. Feb 07, 2017
    • Joshua Colp's avatar
      srv: Fix crash when ast_srv_lookup is used and 0 records are returned. · 5422ec14
      Joshua Colp authored
      When performing an SRV lookup using the ast_srv_lookup function it
      did not properly handle the situation where 0 records are returned.
      If this happened it would wrongly assume that at least one record
      was present.
      
      This change fixes the code so it will exit early if an error occurs
      or if 0 records are returned.
      
      ASTERISK-26772
      patches:
        srv_lookup.patch submitted by nappsoft (license 6822)
      
      Change-Id: I09b19081c74e0ad11c12bf54a257243b1bcb2351
      5422ec14
  23. Feb 03, 2017
    • Sebastien Duthil's avatar
      res_ari: fix memory leak for channelvars · 7b280e7c
      Sebastien Duthil authored
      In ari.conf, when setting the option channelvars, every Stasis channel
      snapshot would create a list of variable/value that would not be freed
      when the snapshot is freed, resulting in a often-recurring memory
      leak.
      
      ASTERISK-26767 #close
      
      Change-Id: Ia37dd9d68063d7f879193df02ede293e5ded716d
      7b280e7c
Loading