Commit graph

28848 commits

Author SHA1 Message Date
Richard Mudgett
2fc65173e5 res_rtp_asterisk.c: Initialize ourip passed to ast_find_ourip().
We access uninitialized memory when the 'ourip' parameter does not
have an initial guess to our IP address.

ASTERISK-26672

Change-Id: I35507ea1ad7455d2be188f6ccdd4add7bd150e15
2016-12-22 12:25:15 -06:00
Richard Mudgett
67cc8499a2 acl.c: Improve ast_ouraddrfor() diagnostic messages.
* Made not generate strings unless they will actually be used.

ASTERISK-26672

Change-Id: I155fbe7fdff5ce47dfe5326f3baf5446849702c3
2016-12-22 12:25:15 -06:00
Joshua Colp
059a54202c Merge "Fixes to various issues reported by pyflakes" 2016-12-21 18:36:52 -06:00
Richard Mudgett
8b7d252987 res_rtp_asterisk.c: Fix off nominal memory leak.
Change-Id: I95b1088d11244a2edae6607c12fbf33b38658a75
2016-12-21 11:15:23 -06:00
Tzafrir Cohen
bab253ac9f Fixes to various issues reported by pyflakes
Pyflake is a python (2) source checker. This patch fixes various
(mostly trivial) errors and warnings it reports.

Change-Id: Ia35c5ac61751b927814cf693994c632c412386ea
2016-12-21 11:02:20 +02:00
Joshua Colp
500c6af9db Merge "pjproject_bundled: Make build single threaded" 2016-12-20 05:31:04 -06:00
Joshua Colp
fb914762ee Merge "res_pjsip: Add/update ERROR msg if invalid URI." 2016-12-20 05:29:56 -06:00
Joshua Colp
270e011fb4 Merge "MESSAGE: Flush Message/ast_msg_queue channel alert pipe." 2016-12-20 05:29:35 -06:00
Joshua Colp
1943ece514 Merge "chan_dahdi.c: Fix bounds check regression." 2016-12-19 19:48:31 -06:00
Joshua Colp
cce4c07d83 Merge "chan_sip: Reorder unload_module to deal with stuck TCP threads." 2016-12-19 16:11:37 -06:00
Joshua Colp
34dc3274d3 Merge "autosupport: Add 'pjproject show buildopts'" 2016-12-19 15:22:47 -06:00
Martin Tomec
f461f65dea app_queue: Ensure member is removed from pending when hanging up.
In some cases member is added to pending_members, and the channel
is hung up before any extension state change. So the member would
stay in pending_members forever. So when we call do_hang, we
should also remove member from pending.

ASTERISK-26621 #close

Change-Id: Iae476b5c06481db18ebe0fa594b3e80fdc9a7d54
2016-12-19 03:45:51 -06:00
George Joseph
d29eb3b99d pjproject_bundled: Make build single threaded
There were just too many issues in various environments with
multi threaded building of pjproject.  It doesn't really speed
things up anyway since asterisk is already being compiled in
parallel.

Change-Id: Ie5648fb91bb89b4224b6bf43a0daa1af793c4ce1
2016-12-18 15:26:53 -06:00
Corey Farrell
8fbb384ea2 chan_sip: Reorder unload_module to deal with stuck TCP threads.
In some situations TCP threads may become frozen.  This creates the
possibility that Asterisk could segfault if they become unfrozen after
chan_sip has been dlclose'd.  This reorders the unload_module process to
allow abort if threads do not exit within 5 seconds.

High level order as follows:
1) Unregister from the core to stop new requests.
2) Signal threads to stop
3) Clear config based tables (but do not free the table itself).
4) Verify that threads have shutdown, cancel unload if not.
5) Clean all remaining resources.

ASTERISK-26586

Change-Id: Ie23692041d838fbd35ece61868f4c640960ff882
2016-12-17 11:25:40 -05:00
David M. Lee
147b8e636e configure: fix with-pjproject-bundled
The AC_ARG_WITH macro's shell variable is withval; not enableval. Purely
coincidentally, the option would work when --enable-dev-mode is given.

Also fixed a portability problem with bootstrap.sh, since -printf is not
a portable option for find.

Change-Id: I0f0e5b1a934b5af5737713834361e9c95b96b376
2016-12-16 01:36:04 -06:00
Richard Mudgett
d27dee3cca autosupport: Add 'pjproject show buildopts'
Change-Id: I8aa55a7c3fb175235ddc7f85e9457d5102d06fa7
2016-12-15 13:27:56 -06:00
Richard Mudgett
9404efa6f4 chan_dahdi.c: Fix bounds check regression.
Caused by ASTERISK-25494

Change-Id: I1fc408c1a083745ff59da5c4113041bbfce54bcb
2016-12-14 14:24:18 -06:00
Richard Mudgett
45a5e2abc6 res_pjsip: Add/update ERROR msg if invalid URI.
ASTERISK-24499

Change-Id: Ie305153e47e922233b2ff24715e0e326e5fa3a6c
2016-12-14 11:38:06 -06:00
Richard Mudgett
44e72c9d44 MESSAGE: Flush Message/ast_msg_queue channel alert pipe.
ASTERISK-25083

Change-Id: Id54baa57a8dbca84e29f28bcd2ffc0a5ac12d8b2
2016-12-14 11:38:06 -06:00
George Joseph
19328de2ab res_sorcery_memory_cache: Change an error to a debug message
When a sorcery user calls ast_sorcery_delete on an object that
may have already expired from the cache, res_sorcery_memory_cache
spits out an ERROR.  Since this can happen frequently and validly when
an inbound registration expires after the cache entry expired, the
errors are unnecessary and misleading.  Changed to a debug/1.

Change-Id: Idf3a67038c16e3da814cf612ff4d6d18ad29ecd7
2016-12-14 08:27:13 -06:00
George Joseph
31268e0a28 pjproject_bundled: Retry download if previously saved tarball is bad
If a tarball is corrupted during download, the makefile will attempt to
download it again. If the tarball somehow gets corrupted after it's
downloaded however, the makefile was just failing.  We now
retry the download.

ASTERISK-26653 #close

Change-Id: I1b24d454852d80186f60c5a65dc4624ea8a1c359
2016-12-09 08:16:39 -06:00
Joshua Colp
2a4b24cc14 Merge "Fix IO conversion bug" 2016-12-09 05:34:02 -06:00
Joshua Colp
3fcc35c66c Merge "res_pjsip: Fix 'A = B != C' kind." 2016-12-09 05:33:26 -06:00
Joshua Colp
963735dfce Merge "Fix typo in chan_sip" 2016-12-09 05:32:44 -06:00
Joshua Colp
b8a0770d74 Merge "chan_sip: Delete unneeded check" 2016-12-09 05:31:46 -06:00
Joshua Colp
91ff772dd7 Merge "Small code cleanup in chan_sip" 2016-12-09 05:31:33 -06:00
Joshua Colp
cc9b30dd27 Merge "res_pjsip_registrar: AMI Add RegistrationInboundContactStatuses command" 2016-12-09 05:30:02 -06:00
Badalyan Vyacheslav
4c6ba1dbba Fix typo in chan_sip
The conditional expressions of the 'if' operators
situated alongside each other are identical.

Change-Id: I652b6dcddb3be007e669a6aa8107edb31a1ddafb
2016-12-08 16:53:56 -06:00
Badalyan Vyacheslav
934aa2c768 res_pjsip: Fix 'A = B != C' kind.
Consider reviewing the expression of the 'A = B != C' kind.
The expression is calculated as following: 'A = (B != C)'

Change-Id: Ibaa637dfda47d51a20e26069d3103e05ce80003d
2016-12-08 16:53:12 -06:00
Badalyan Vyacheslav
51118e7d70 chan_sip: Delete unneeded check
P is always true. We check it before

Change-Id: Iee61cda002a9f61aee26b9f66c5f9b59e3389efb
2016-12-08 13:17:40 -06:00
Badalyan Vyacheslav
fe5be81821 Small code cleanup in chan_sip
The conditional expressions of the 'if' operators situated
alongside each other are identical.

Change-Id: I2cf7c317b106ec14440c7f1b5dcfbf03639f748a
2016-12-08 18:58:19 +00:00
Badalyan Vyacheslav
149d8db96c Fix IO conversion bug
Expression 'rlen < 0' is always false.
Unsigned type value is never < 0.

Change-Id: Id9f393ff25b009a6c4a6e40b95f561a9369e4585
2016-12-08 18:34:28 +00:00
Kevin Harwell
5a96e1fb5e Merge "res_format_attr_opus: Fix crash when fmtp contains spaces." 2016-12-08 11:06:24 -06:00
Walter Doekes
c796f00c35 chan_sip: Do not allow non-SP/HTAB between header key and colon.
RFC says SIP headers look like:

    HCOLON  =  *( SP / HTAB ) ":" SWS
    SWS     =  [LWS]                    ; sep whitespace
    LWS     =  [*WSP CRLF] 1*WSP        ; linear whitespace
    WSP     =  SP / HTAB                ; from rfc2234

chan_sip implemented this:

    HCOLON  =  *( LOWCTL / SP ) ":" SWS
    LOWCTL  = %x00-1F                   ; CTL without DEL

This discrepancy meant that SIP proxies in front of Asterisk with
chan_sip could pass on unknown headers with \x00-\x1F in them, which
would be treated by Asterisk as a different (known) header.  For
example, the "To\x01:" header would gladly be forwarded by some proxies
as irrelevant, but chan_sip would treat it as the relevant "To:" header.

Those relying on a SIP proxy to scrub certain headers could mistakenly
get unexpected and unvalidated data fed to Asterisk.

This change fixes so chan_sip only considers SP/HTAB as valid tokens
before the colon, making it agree on the headers with other speakers of
SIP.

ASTERISK-26433 #close
AST-2016-009

Change-Id: I78086fbc524ac733b8f7f78cb423c91075fd489b
2016-12-08 08:19:38 -06:00
Joshua Colp
2268834c41 Merge "tests_dns: Make DNS tests older nameser.h compatible" 2016-12-08 08:09:07 -06:00
Joshua Colp
5c89604a32 res_format_attr_opus: Fix crash when fmtp contains spaces.
When an opus offer or answer was received that contained an
fmtp line with spaces between the attributes the module would
fail to properly parse it and crash due to recursion.

This change makes the module handle the space properly and
also removes the recursion requirement.

ASTERISK-26579

Change-Id: I01f53e5d9fa9f1925a7365f8d25071b5b3ac2dc3
2016-12-08 11:47:30 +00:00
George Joseph
79b09b5f18 res_pjsip_registrar: AMI Add RegistrationInboundContactStatuses command
The PJSIPShowRegistrationsInbound AMI command was just dumping out
all AORs which was pretty useless and resource heavy since it had
to get all endpoints, then all aors for each endpoint, then all
contacts for each aor.

PJSIPShowRegistrationInboundContactStatuses sends ContactStatusDetail
events which meets the intended purpose of the other command and has
significantly less overhead.  Also, some additional fields that were
added to Contact since the original creation of the ContactStatusDetail
event have been added to the end of the event.

For compatibility purposes, PJSIPShowRegistrationsInbound is left
intact.

ASTERISK-26644 #close

Change-Id: I326f12c9ecb52bf37ba03f0748749de4da01490a
2016-12-07 18:11:28 -06:00
snuffy
3b6e6cd01c tests_dns: Make DNS tests older nameser.h compatible
Fix the tests for DNS to use older style nameser.h as
in ASTERISK-26608.

Tested on: OpenBSD 6.0, Debian 8

ASTERISK-26647 #close

Change-Id: I285913c44202537c04b3ed09c015efa6e5f9052d
2016-12-08 07:22:33 +11:00
Joshua Colp
1067b9add3 Merge "Bundled pjproject: Fix finding SIP transactions." 2016-12-07 13:38:25 -06:00
Joshua Colp
18fe80e776 Merge "http: Send headers and body in one write." 2016-12-07 13:37:31 -06:00
Joshua Colp
119c41d001 Merge "Iostreams: Correct off-by-one error." 2016-12-07 13:37:20 -06:00
Richard Mudgett
76d52dc228 Bundled pjproject: Fix finding SIP transactions.
Occasionally SIP message transactions are not found when they should be.
In the particular case an incoming INVITE transaction is CANCELed but the
INVITE transaction cannot be found so a 481 response is returned for the
CANCEL.  The problematic calls have a '_' character in the Via branch
parameter.

The problem is in the pjproject PJ_HASH_USE_OWN_TOLOWER feature's code.
The problem with the "own tolower" code is that it does not calculate the
same hash value as when the pj_tolower() function is used.  The "own
tolower" code will erroneously modify the ASCII characters '@', '[', '\\',
']', '^', and '_'.  Calls to pj_hash_calc_tolower() can use the
PJ_HASH_USE_OWN_TOLOWER substitute algorithm when enabled.  Calls to
pj_hash_get_lower(), pj_hash_set_lower(), and pj_hash_set_np_lower() call
find_entry() which never uses the PJ_HASH_USE_OWN_TOLOWER algorithm.  As a
result you may not be able to find a hash tabled entry because the
calculated hash values would differ.

* Simply disable PJ_HASH_USE_OWN_TOLOWER.

ASTERISK-26490 #close

Change-Id: If89bfdb5f301b8b685881a9a2a6e0c3c5af32253
2016-12-07 06:16:48 -06:00
Mark Michelson
503006123a http: Send headers and body in one write.
This is a semi-regression caused by the iostreams change. Prior to
iostreams, HTTP headers were written to a FILE handle using fprintf.
Then the body was written using a call to fwrite(). Because of internal
buffering, the result was that the HTTP headers and body would be sent
out in a single write to the socket.

With the change to iostreams, the HTTP headers are written using
ast_iostream_printf(), which under the hood calls write(). The HTTP body
calls ast_iostream_write(), which also calls write() under the hood.
This results in two separate writes to the socket.

Most HTTP client libraries out there will handle this change just fine.
However, a few of our testsuite tests started failing because of the
change. As a result, in order to reduce frustration for users, this
change alters the HTTP code to write the headers and body in a single
write operation.

ASTERISK-26629 #close
Reported by Joshua Colp

Change-Id: Idc2d2fb3d9b3db14b8631a1e302244fa18b0e518
2016-12-07 05:10:32 -06:00
Mark Michelson
bf6423a336 Iostreams: Correct off-by-one error.
ast_iostream_printf() attempts first to use a fixed-size buffer to
perform its printf-like operation. If the fixed-size buffer is too
small, then a heap allocation is used instead. The heap allocation in
this case was exactly the length of the string to print. The issue here
is that the ensuing call to vsnprintf() will print a NULL byte in the
final space of the string. This meant that the final character was being
chopped off the string and replaced with a NULL byte. For HTTP in
particular, this caused problems because HTTP publishes the expected
Contact-Length. This meant HTTP was publishing a length one character
larger than what was actually present in the message.

This patch corrects the issue by adding one to the allocation length.

ASTERISK-26629
Reported by Joshua Colp

Change-Id: Ib3c5f41e96833d0415cf000656ac368168add639
2016-12-06 12:34:51 -06:00
George Joseph
fe9f070885 pjproject_bundled: Fix missing inclusion of symbols
Added back in a -g3, and an -O3 when DONT_OPTIMIZE is not set, to
the CFLAGS.  Not sure how they went missing.

Also fixed an uninstall problem where we weren't removing the
symlink from libasteriskpj.so.2 to libasteriskpj.so.  While I was
there, I fixed it for libasteriskssl as well.

Change-Id: I9e00873b1e9082d05b5549d974534b48a2142556
2016-12-06 12:21:12 -06:00
Joshua Colp
faf2194fab Merge "app_originate: Add option to execute gosub prior to dial" 2016-12-06 05:34:54 -06:00
zuul
8bd9dc568a Merge "res_pjsip_outbound_registration.c: Filter redundant statsd reporting." 2016-12-05 22:00:27 -06:00
Joshua Colp
2a415187c5 Merge "res_pjsip/chan_sip: Advertise 'ws' in the SIP URI transport parameter" 2016-12-02 12:27:52 -06:00
Richard Mudgett
4b3d3fc741 res_pjsip_outbound_registration.c: Filter redundant statsd reporting.
Increasing the testsuite shutdown timeout before forcibly killing
Asterisk allowed more events to be sent out.  Some tests failed as
a result.  The tests/channels/pjsip/statsd/registrations failed
because we now get the statsd events that a comment in the test
configuration stated couldn't be intercepted.  Unfortunately, we
get a variable number of events because of internal status state
transition races generating redundant statsd events.

We were reporting redundant statsd PJSIP.registrations.state changes
for internal state changes that equated to the same thing publicly.

* Made update_client_state_status() filter out redundant statsd
updates.

ASTERISK-26527

Change-Id: If851c7d514bb530d9226e4941ba97dcf52000646
2016-12-02 11:56:59 -06:00
Joshua Colp
cd5d9d1d69 Merge "tcptls: Use new certificate upon sip reload" 2016-12-02 07:15:08 -06:00