Commit Graph

2953 Commits

Author SHA1 Message Date
Russell Bryant
40520cc2a4 Fix a race condition that bbryant just found while doing some IAX2 testing.
He was running Asterisk trunk running IAX2 calls through a few Asterisk boxes,
however, the audio was extremely choppy.  We looked at a packet trace and saw
a storm of INVAL and VNAK frames being sent from one box to another.

It turned out that what had happened was that one box tried to send a CONTROL
frame before the 3 way handshake had completed.  So, that frame did not include
the destination call number, because it didn't have it yet.  Part of our recent
work for security issues included an additional check to ensure that frames that
are supposed to include the destination call number have the correct one.  This
caused the frame to be rejected with an INVAL.  The frame would get retransmitted
for forever, rejected every time ...

This race condition exists in all versions that got the security changes,
in theory.  However, it is really only likely that this would cause a problem in
Asterisk trunk.  There was a control frame being sent (SRCUPDATE) at the _very_
beginning of the call, which does not exist in 1.2 or 1.4.  However, I am fixing
all versions that could potentially be affected by the introduced race condition.

These changes are what bbryant and I came up with to fix the issue.  Instead of
simply dropping control frames that get sent before the handshake is complete,
the code attempts to wait a little while, since in most cases, the handshake
will complete very quickly.  If it doesn't complete after yielding for a little
while, then the frame gets dropped.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@115564 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-08 19:14:04 +00:00
Russell Bryant
c5c3cb32f1 Remove remnants of dlinkedlists. I didn't actually use them in the final version
of my IAX2 improvements.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@115511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-07 16:22:49 +00:00
Russell Bryant
f8d551bd2b Merge changes from team/russell/iax2_find_callno_1.2
These changes address a critical performance issue introduced in the latest
release.  The fix for the latest security issue included a change that made
Asterisk randomly choose call numbers to make them more difficult to guess by
attackers.  However, due to some inefficient (this is by far, an understatement)
code, when Asterisk chose high call numbers, chan_iax2 became unusable after
just a small number of calls.  On a small embedded platform, it would not be
able to handle a single call.  On my Intel Core 2 Duo @ 2.33 GHz, I couldn't
run more than about 16 IAX2 channels.  Ouch.

These changes address some performance issues of the find_callno() function
that have bothered me for a very long time.  On every incoming media frame,
it iterated through every possible call number trying to find a matching
active call.  This involved a mutex lock and unlock for each call number
checked.  So, if the random call number chosen was 20000, then every media
frame would cause 20000 locks and unlocks.  Previously, this problem was
not as obvious since Asterisk always chose the lowest call number it could.

A second container for IAX2 pvt structs has been added.  It is an astobj2
hash table.  When we know the remote side's call number, the pvt goes into
the hash table with a hash value of the remote side's call number.  Then,
lookups for incoming media frames are a very fast hash lookup instead of an
absolutely insane array traversal.

In a quick test, I was able to get more than 3600% more IAX2 channels
on my machine with these changes.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@115296 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-05 17:53:26 +00:00
Russell Bryant
38419fb811 When we receive a full frame that is supposed to contain our call number,
ensure that it has the correct one.
(closes issue #10078)
(AST-2008-006)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@114561 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-22 22:20:35 +00:00
Russell Bryant
62766834c8 Fix some very broken code that was introduced in 1.2.26 as a part of the security
fix.  The dnsmgr is not appropriate here.  The dnsmgr takes a pointer to an address
structure that a background thread continuously updates.  However, in these cases,
a stack variable was passed.  That means that the dnsmgr thread would be continuously
writing to bogus memory.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@110335 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-20 21:53:27 +00:00
Jason Parker
866bf7984a Do not return with a successful authentication if the From header ends up empty.
(AST-2008-003)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@109391 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-18 15:08:41 +00:00
Tilghman Lesher
47b472894b Fix for fix for security fix (third time's the charm?)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@94661 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-23 01:30:42 +00:00
Russell Bryant
4208af2204 Fix another potential seg fault ...
(closes issue #11606)
Reported by: dimas


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@94255 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-20 20:21:41 +00:00
Russell Bryant
04e4f3d345 Fix a couple of places where it's possible to dereference a NULL pointer.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@94214 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-20 17:29:11 +00:00
Tilghman Lesher
0f7afb14e4 Oops, missed this one case
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@93675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-18 18:44:41 +00:00
Tilghman Lesher
1e6902b29d Fixing AST-2007-027 (Closes issue #11119)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@93667 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-18 18:23:06 +00:00
Russell Bryant
0edee75c07 Revert patch committed for issue #9660. It broke E&M trunks.
(closes issue #10360)
(closes issue #10364)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@78370 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-07 17:44:04 +00:00
Steve Murphy
32ade7d7fc this fixes bug 10293, where the error message because defaultzone or loadzone was not defined was confusing
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@76978 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-25 00:07:24 +00:00
Jason Parker
f95db061fd Don't create the Asterisk channel until we are starting the PBX on it.
(ASA-2007-018)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@76802 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-24 16:32:04 +00:00
Joshua Colp
a62bba55d8 (closes issue #5866)
Reported by: tyler
Do not force channel format changes when a generator is present. The generator may have changed the formats itself and changing them back would cause issues.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@76653 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 18:28:13 +00:00
Joshua Colp
2405536de9 (closes issue #10236)
Reported by: homesick
Patches:
      rpid_1.4_75840.patch uploaded by homesick (license 91)
Accept Remote Party ID on guest calls.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@76560 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-23 14:32:07 +00:00
Russell Bryant
831ebbebb7 Backport a fix for a memory leak that was fixed in trunk in reivision 76221
by rizzo.  The memory used for the localaddr list was not freed during a
configuration reload.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@76226 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-21 02:01:46 +00:00
Joshua Colp
a7047b7ed5 (closes issue #10247)
Reported by: fkasumovic
Patches:
      chan_sip.patch uploaded by fkasumovic (license #101)
Drop any peer realm authentication entries when reloading so multiple entries do not get added to the peer.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@76080 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-20 17:16:48 +00:00
Russell Bryant
9df29ba46f When processing full frames, take sequence number wraparound into account when
deciding whether or not we need to request retransmissions by sending a VNAK.
This code could cause VNAKs to be sent erroneously in some cases, and to not
be sent in other cases when it should have been.
(closes issue #10237, reported and patched by mihai)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@75927 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-19 15:49:42 +00:00
Russell Bryant
6b5a7a6f64 When traversing the queue of frames for possible retransmission after
receiving a VNAK, handle sequence number wraparound so that all frames that 
should be retransmitted actually do get retransmitted.
(issue #10227, reported and patched by mihai)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@75757 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-18 21:09:13 +00:00
Russell Bryant
d359de6edb Properly check for the length in the skinny packet to prevent an invalid memcpy.
(ASA-2007-016)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@75449 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-17 20:57:09 +00:00
Russell Bryant
d0b4144eb4 Ensure that when encoding the contents of an ast_frame into an iax_frame, that
the size of the destination buffer is known in the iax_frame so that code
won't write past the end of the allocated buffer when sending outgoing frames.
(ASA-2007-014)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@75444 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-17 20:45:27 +00:00
Russell Bryant
d2cb9b0d3b After parsing information elements in IAX frames, set the data length to zero,
so that code later on does not think it has data to copy.
(ASA-2007-015)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@75440 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-17 20:41:41 +00:00
Russell Bryant
460df0480b (closes issue #9660)
Reported by: mmacvicar
Patches submitted by: bbryant, russell
Tested by: mmacvicar, marco, arcivanov, jmhunter, explidous

When using a TDM400P (and probably other analog cards) there was a chance that
you could hang up and pick the phone back up where it has been long enough to
be not considered a flash hook, but too soon such that the device reports that
it is busy and the person on the phone will only hear silence.  This patch
makes chan_zap more tolerant of this and gives the device a couple of seconds 
to succeed so the person on the phone happily gets their dialtone.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@75052 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-13 19:10:00 +00:00
Russell Bryant
2c757b4ab7 The function make_trunk() can fail and return -1 instead of a valid new call
number.  Fix the uses of this function to handle this instead of treating it
as the new call number.  This would cause a deadlock and memory corruption.
(possible cause of issue #9614 and others, patch by me)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@74766 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-11 22:53:26 +00:00
Mark Michelson
140c936792 The cli command "agent logoff Agent/x soft" did not work...at all. Now it does.
(closes issue #10178, reported and patched by makoto, with slight modification for 1.4 and trunk by me)



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@74719 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-11 21:12:30 +00:00
Joshua Colp
7055d9fe45 Use some Makefile magic to determine if linux/compiler.h is present. (issue #10174 reported by francesco_r)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@74587 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-11 17:15:11 +00:00
Jason Parker
5dd56e420c Fix an issue with wrapuptime not working when using AgentLogin.
Issue 10169, patch by makoto, with a minor mod by me to not re-break issue 9618


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@74376 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-10 19:03:45 +00:00
Jason Parker
29da454042 Several chan_zap options were not working on reload because they were arbitrarily
disallowed when reloading some/most PRI options (such as signalling) was disallowed.

Options such as polarityonanswerdelay and answeronpolarityswitch can safely be changed on a reload.
This corrects that behavior.

Issue 9186, patch by tzafrir.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@74158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-09 20:18:15 +00:00
Russell Bryant
0a22a51525 If a sip_pvt struct has already registered an extension state callback,
remove the old one before adding a new one.  If this isn't done, Asterisk
will crash.  (issue #10120)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73768 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-06 23:01:22 +00:00
Russell Bryant
ed261253d5 (closes issue #10125)
Reported by: makoto
Patches submitted by: makoto

This fixes a crash in chan_sip that happens when the bindaddr setting is not
valid on Asterisk startup, gets fixed, and then a reload gets issued.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73678 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-06 15:55:41 +00:00
Mark Michelson
3735871ed4 Fixed a bug wherein agents get stuck busy. (issue 9618, reported by jiddings, patched by moi)
closes issue #9618



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73674 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-06 15:26:40 +00:00
Kevin P. Fleming
585de1223e we shouldn't allow G.723.1 endpoints to use VAD, just like we don't support it for G.729
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73547 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-05 22:11:51 +00:00
Joshua Colp
0b2c98ac3e Copy language information to the dialog structure when calling a peer for situations where a PBX may be started on the dialed channel. (issue #10121 reported by clegall_proformatique)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73466 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-05 19:15:18 +00:00
Joshua Colp
1dc2b9c0f7 Actually check to make sure a PBX was started on one of the Local channels instead of blindly assuming it was. (issue #10112 reported by makoto)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73318 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-05 13:26:02 +00:00
Christian Richter
ce99e9d955 bchannel configurations like echocancel and volume control, need to be setuped on inbound calls too.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73252 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-04 14:50:58 +00:00
Christian Richter
479d7e4738 bad bug in overlapdial case, we called start_pbx multiple times, because the state wasn't changed..
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73207 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-04 08:20:54 +00:00
Christian Richter
2676d6c595 fixed issue, that misdn_l2l1_check could only be called from mISDN Source channels.. #9449
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@73004 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-03 08:04:35 +00:00
Russell Bryant
defd4eb3e2 Backport changes that make chan_iax2 not start the PBX on an incoming channel
until the three-way call setup is completed.  These changes are already in 1.4
and trunk.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@72629 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-29 16:30:56 +00:00
Christian Richter
fc4111b44f check if the bchannel stack id is already used, if so don't use it a second time. Also added a release_chan lock, so that the same chan_list object cannot be freed twice. chan_misdn does not crash anymore on heavy load with these changes.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@72585 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-29 13:08:26 +00:00
Christian Richter
3637816f4c simplified generation for dummy bchannels, also we mark them as dummies, so they are not used later as real-bchannels, optimized the RESTART mechanisms, we block a channel now on cause:44, and send out a RESTART automatically, then on reception of RESTART_ACKNOWLEDGE we unblock the channel again.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@72099 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-27 13:22:37 +00:00
Christian Richter
5f272436b9 simplified channel finding and locking a lot. removed unnecessary #ifdefed areas.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@72087 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-27 09:26:53 +00:00
Christian Richter
085065ac35 isdn_lib.c didn't compile
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@72041 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-27 07:54:30 +00:00
Christian Richter
16ecedee04 for inbound TE calls, we setup the bchannel when we get the CONNECT_ACKNOWLEDGE, to make sure mISDN has everything ready. removed some #if 0 areas which weren't used anymore.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@72040 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-27 07:49:27 +00:00
Joshua Colp
76b4eb5daa Ignore other URIs after the first in a 300 Multiple Choice response. (issue #10041 reported by homesick)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@71414 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-25 01:02:49 +00:00
Christian Richter
d8d4454ae5 we activate the bchannels in TE mode on incoming calls only when we want to connect the call.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@70672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-21 13:11:29 +00:00
Joshua Colp
6357ad5659 Don't overwrite the configured username setting upon a REGISTER. (issue #8565 reported by jsmith)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@70551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-20 22:20:16 +00:00
Russell Bryant
cfaead2b9c Fix a problem where an established call would not be properly disconnected
when a PRI disconnect is received depending on which cause code was received.
(issue #9588, original patch by softins, updated patch from jtexter3, and some
 additional feedback from mhardeman)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@70396 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-20 18:45:38 +00:00
Christian Richter
f5f018a209 forgot one place ..
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@70342 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-20 15:42:39 +00:00
Christian Richter
7fc236e53b fixed a bug that was introduced by copy and paste in the last commit ..bchannels weren't cleaned properly.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@70341 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-20 15:29:09 +00:00