Commit graph

30284 commits

Author SHA1 Message Date
Corey Farrell
0bda39c668 DEBUG_FD_LEAKS: Add missing FD creators.
This adds FD tracking for the following functions:
* eventfd
* timerfd_create
* socketpair
* accept

ASTERISK-27404

Change-Id: Id6848fe904ade2d34eb39d2a20bd6b223e1111fc
2017-11-08 13:57:45 -05:00
Corey Farrell
05f557820b bridge_softmix: Note why ast_stream_topology_set_stream cannot fail.
This appeared in my audit of ast_stream_topology_set_stream callers
not checking for errors but in this situation the call cannot fail.
Add comment so this can be ignored in the future.

Change-Id: I91d25704859efbe50b8b82cfe1cd3c40ba177c9f
2017-11-08 11:14:13 -05:00
George Joseph
38669ac57a Merge "AST-2017-009: pjproject: Add validation of numeric header values" 2017-11-08 09:52:47 -06:00
George Joseph
9c024497e9 Merge "AST-2017-011 - res_pjsip_session: session leak when a call is rejected" 2017-11-08 09:45:24 -06:00
George Joseph
9e69c78d6f Merge "AST-2017-010: Fix cdr_object_update_party_b_userfield_cb() buf overrun" 2017-11-08 08:25:54 -06:00
Joshua Colp
698ff5b4cb Merge "res_pjproject.c: Fix ast_strdup() alloc failure." 2017-11-08 07:38:45 -06:00
Kevin Harwell
dd1a914495 AST-2017-011 - res_pjsip_session: session leak when a call is rejected
A previous commit made it so when an invite session transitioned into a
disconnected state destruction of the Asterisk pjsip session object was
postponed until either a transport error occurred or the event timer
expired. However, if a call was rejected (for instance a 488) before the
session was fully established the event timer may not have been initiated,
or it was canceled without triggering either of the session finalizing states
mentioned above.

Really the only time destruction of the session should be delayed is when a
BYE is being transacted. This is because it's possible in some cases for the
session to be disconnected, but the BYE is still transacting.

This patch makes it so the session object always gets released (no more
memory leak) when the pjsip session is in a disconnected state. Except when
the method is a BYE. Then it waits until a transport error occurs or an event
timeout.

ASTERISK-27345 #close

Reported by: Corey Farrell

Change-Id: I1e724737b758c20ac76d19d3611e3d2876ae10ed
2017-11-08 05:49:59 -07:00
Richard Mudgett
b358e441cd AST-2017-010: Fix cdr_object_update_party_b_userfield_cb() buf overrun
cdr_object_update_party_b_userfield_cb() could overrun the fixed buffer if
the supplied string is too long.  The long string could be supplied by
external means using the CDR(userfield) function.

This may seem reminiscent to AST-2017-001 (ASTERISK_26897) and it is.  The
earlier patch fixed the buffer overrun for Party A's userfield while this
patch fixes the same thing for Party B's userfield.

ASTERISK-27337

Change-Id: I0fa767f65ecec7e676ca465306ff9e0edbf3b652
2017-11-08 05:41:12 -07:00
George Joseph
74432f51f9 AST-2017-009: pjproject: Add validation of numeric header values
Parsing the numeric header fields like cseq, ttl, port, etc. all
had the potential to overflow, either causing unintended values to
be captured or, if the values were subsequently converted back to
strings, a buffer overrun.  To address this, new "strto" functions
have been created that do range checking and those functions are
used wherever possible in the parser.

 * Created pjlib/include/limits.h and pjlib/include/compat/limits.h
   to either include the system limits.h or define common numeric
   limits if there is no system limits.h.

 * Created strto*_validate functions in sip_parser that take bounds
   and on failure call the on_str_parse_error function which prints
   an error message and calls PJ_THROW.

 * Updated sip_parser to validate the numeric fields.

 * Fixed an issue in sip_transport that prevented error messages
   from being properly displayed.

 * Added "volatile" to some variables referenced in PJ_CATCH blocks
   as the optimizer was sometimes optimizing them away.

 * Fixed length calculation in sip_transaction/create_tsx_key_2543
   to account for signed ints being 11 characters, not 9.

ASTERISK-27319
Reported by: Youngsung Kim at LINE Corporation

Change-Id: I48de2e4ccf196990906304e8d7061f4ffdd772ff
2017-11-08 05:26:54 -07:00
Jenkins2
b7f64c30e2 Merge "stream: Return error from ast_stream_topology_set_stream." 2017-11-08 06:06:51 -06:00
Joshua Colp
d91d0e992d Merge "res_stasis: Fix multiple leaks." 2017-11-08 04:58:12 -06:00
Corey Farrell
2c4db2a3d5 res_pjsip_pubsub: Fix multiple leaks on failure to append vectors.
Change-Id: I68ece0073ea79667ca41eb10405f516f1d30d482
2017-11-07 22:38:16 -05:00
Corey Farrell
48e96aba6a res_pjsip_history: Fix multiple leaks on vector append failure.
Change-Id: I41e8d5183ace284095cc721f3b1fb32ade3f940f
2017-11-07 22:31:12 -05:00
Corey Farrell
ecb81ae4de res_pjsip_session: Fix multiple leaks.
* Pre-initialize cloned media state vectors to final size to ensure
  vector errors cannot happen later in the clone initialization.
* Release session_media on vector replace failure in
  ast_sip_session_media_state_add.
* Release clone and media_state in ast_sip_session_refresh if we fail to
  append to the stream topology, return an error.

Change-Id: Ib5ffc9b198683fa7e9bf166d74d30c1334c23acb
2017-11-07 22:23:59 -05:00
Jenkins2
0129e396b2 Merge "res_pjsip_outbound_registration: Fix leak on vector add failure." 2017-11-07 20:39:31 -06:00
Jenkins2
ca5bffb305 Merge "res_pjsip_exten_state: Check for vector append failure." 2017-11-07 20:06:27 -06:00
Jenkins2
ebd9e5c8c3 Merge "res_pjsip_config_wizard: Fix leaks and add check for malloc failure." 2017-11-07 19:41:46 -06:00
Jenkins2
13ffdfd96a Merge "res_stasis_playback: Check for failure to append vector." 2017-11-07 19:02:20 -06:00
Jenkins2
d6213397f0 Merge "res_pjsip: Fix leak on error in ast_sip_auth_vector_init." 2017-11-07 18:14:28 -06:00
Jenkins2
250d905fc3 Merge "test_sorcery_memory_cache_thrash: Handle error from vector append." 2017-11-07 17:32:48 -06:00
Jenkins2
2dcd0c8a05 Merge "stasis: Release object if vector append fails." 2017-11-07 16:40:50 -06:00
Jenkins2
759f4c1125 Merge "res_ari_events: Fix use after free / double-free of JSON message." 2017-11-07 16:10:11 -06:00
Jenkins2
bd67e63434 Merge "PBX: Handle errors from AST_VECTOR_APPEND." 2017-11-07 15:27:26 -06:00
Jenkins2
64fa84b2ca Merge "Messaging: Report error on failure to register tech or handler." 2017-11-07 14:58:05 -06:00
Jenkins2
3d5aa21fe5 Merge "format_cap: Fix leak on AST_VECTOR_APPEND error." 2017-11-07 14:20:02 -06:00
Jenkins2
b52d53b6dc Merge "CLI: Remove unused internal command." 2017-11-07 13:02:30 -06:00
Jenkins2
fdba5fce58 Merge "res_pjsip: Avoid crash when contact uri is empty string" 2017-11-07 12:08:44 -06:00
Corey Farrell
9b3db9a7fd main/sdp_state: Check for errors from ast_stream_topology_set_stream.
Change-Id: I84a83ae69daba5d185cc1d939b133a4c23565497
2017-11-07 13:03:34 -05:00
Richard Mudgett
0cfc3cbf02 res_pjsip_registrar.c: Fix AOR and pjproject group deadlock.
One of the patches for ASTERISK_27147 introduced a deadlock regression.
When the connection oriented transport shut down, the code attempted to
remove the associated contact.  However, that same transport had just
requested a registration that we hadn't responded to yet.  Depending
upon timing we could deadlock.

* Made send the REGISTER response after we completed processing the
request contacts and released the AOR lock to avoid the deadlock.

ASTERISK-27391

Change-Id: I89a90f87cb7a02facbafb44c75d8845f93417364
2017-11-07 13:01:25 -05:00
Corey Farrell
eba1179795 res_pjsip_session: Check for errors from ast_stream_topology_set_stream.
Free memory and return error if ast_stream_topology_set_stream fails.

Change-Id: I9f4dbf44bed627243d2f1dd8aea2eab6c38a028d
2017-11-07 12:40:08 -05:00
Corey Farrell
4ac6dd4e95 res_pjsip_t38: Better error checking for t38_create_media_state.
Change-Id: I81b2587427c6982aa3e2a3f9ad69cce8d316eb10
2017-11-07 12:34:19 -05:00
Jenkins2
06746b0af5 Merge "res_pjsip: Ignore empty TLS configuration" 2017-11-07 11:05:13 -06:00
Corey Farrell
fb18895108 stream: Return error from ast_stream_topology_set_stream.
ast_stream_topology_set_stream had suppressed error codes from
AST_VECTOR_APPEND.  The result of AST_VECTOR_APPEND needs to be returned
to the caller so they can take appropriate action on the stream.

Change-Id: I6c0d12755743eadba1357f6153526cc055592856
2017-11-07 11:28:53 -05:00
Corey Farrell
801094da7b res_stasis: Fix multiple leaks.
* res/stasis/app.c JSON passed to app_send needs to be released.
* res/stasis_message.c: objects leak if vector append fails.

Change-Id: I8dd5385b9f50a5cadf2b1d16efecffd6ddb4db4a
2017-11-07 11:24:48 -05:00
Joshua Colp
3c897daabf Merge "tcptls: Print notice when TLS is enabled but not configured." 2017-11-07 10:12:41 -06:00
Joshua Colp
83c61383c8 Merge "stasis: Remove silly use of RAII_VAR in stasis_forward_all." 2017-11-07 09:32:45 -06:00
Joshua Colp
a34b36c513 Merge "stasis_channels.c: Remove a very silly RAII_VAR()." 2017-11-07 08:44:12 -06:00
Joshua Colp
a576d7c2e4 Merge "stasis/app.c: Optimize stasis_app_get_debug_by_name()" 2017-11-07 07:57:39 -06:00
Joshua Colp
e7c52d1b61 Merge "Fix ast_(v)asprintf() malloc failure usage conditions." 2017-11-07 07:18:12 -06:00
Richard Mudgett
02329b9a34 res_pjproject.c: Fix ast_strdup() alloc failure.
Change-Id: I74688038e7afe3a279359cce53aadb28ade51ead
2017-11-07 08:11:32 -05:00
Aaron An
a36d8cc533 res_pjsip: Avoid crash when contact uri is empty string
Asterisk will crash if contact uri is invalid, so contact_apply_handler
should check if the uri is NULL or empty.

ASTERISK-27393 #close
Reported-by: Aaron An
Tested-by: AaronAn

Change-Id: Ia0309bdc6b697c73c9c736e1caec910b77ca69f5
2017-11-07 08:01:08 -05:00
Joshua Colp
5407291ec6 Merge "RTP Engine: Deal with errors returned from AST_VECTOR_REPLACE." 2017-11-07 06:36:32 -06:00
Corey Farrell
7ef38d399a res_pjsip_outbound_registration: Fix leak on vector add failure.
Change-Id: I774b88b3c9da41edd4dc8d78f095481f52f2bd46
2017-11-06 18:55:00 -05:00
Corey Farrell
8684219f79 res_pjsip_exten_state: Check for vector append failure.
Release reference to publisher if we fail to add it to the vector.

Change-Id: I64dff3f481b67b9884f37cadba7a5ccf23d084f3
2017-11-06 18:48:06 -05:00
Corey Farrell
f899368cd6 res_pjsip_config_wizard: Fix leaks and add check for malloc failure.
wizard_apply_handler():
- Free host if we fail to add it to the vector.

wizard_mapped_observer():
- Check for otw allocation failure.
- Free otw if we fail to add it to the vector.

Change-Id: Ib5d3bcabbd9c24dd8a3c9cc692a794a5f60243ad
2017-11-06 18:44:01 -05:00
Corey Farrell
4016884ef3 res_stasis_playback: Check for failure to append vector.
Free resources and return error if we fail to append the vector in
stasis_app_control_play_uri.

Change-Id: I22c4a90dd859b253f2850c6511de48b25609422b
2017-11-06 18:38:35 -05:00
Corey Farrell
24b9751aaa test_sorcery_memory_cache_thrash: Handle error from vector append.
Cleanup resources when we fail to append the vector and report test
failure.

Change-Id: I6eb41586fd11dee8c0dfe35e91cb465a4cab7298
2017-11-06 18:33:13 -05:00
Corey Farrell
29205e7adc res_pjsip: Fix leak on error in ast_sip_auth_vector_init.
Change-Id: Ib0fc7a18f3135ca8990c3984c9e15f6d26e556e8
2017-11-06 18:28:35 -05:00
Corey Farrell
70fcc043bb res_pjproject: Handle error from adding to the buildopts vector.
Change-Id: I076c7bd207c7989a23005395ce1735392657be65
2017-11-06 18:17:13 -05:00
Corey Farrell
5247ba4b88 res_ari_events: Fix use after free / double-free of JSON message.
When stasis_app_message_handler needs to queue a message for a later
connection it needs to bump the message reference so it doesn't get
freed when the caller releases it's reference.

Change-Id: I82696df8fe723b3365c15c3f7089501da8daa892
2017-11-06 18:11:08 -05:00