]> git.ipfire.org Git - thirdparty/asterisk.git/commit
Fix potential buffer overrun and memory leak when executing "sip show peers"
authorMatthew Jordan <mjordan@digium.com>
Wed, 22 Feb 2012 14:50:20 +0000 (14:50 +0000)
committerMatthew Jordan <mjordan@digium.com>
Wed, 22 Feb 2012 14:50:20 +0000 (14:50 +0000)
commit645335276827688f5f200611d7381ab28406322c
treee64350f6e506c971a1b76c0bf43d4f073fc203eb
parente880b4a2057d3885b136dae826ec745f2be2e7ed
Fix potential buffer overrun and memory leak when executing "sip show peers"

The "sip show peers" command uses a fix sized array to sort the current peers
in the peers ao2_container.  The size of the array is based on the current
number of peers in the container.  However, once the size of the array is
determined, the number of peers in the container can change, as the peers
container is not locked.  This could cause a buffer overrun when populating
the array, if peers were added to the container after the array was created.
Additionally, a memory leak of the allocated array would occur if a user
caused the _show_peers method to return CLI_SHOWUSAGE.

We now create a snapshot of the current peers using an ao2_callback with the
OBJ_MULTIPLE flag.  This size of the array is set to the number of peers
that the iterator will iterate over; hence, if peers are added or removed
from the peers container it will not affect the execution of the "sip show
peers" command.

Review: https://reviewboard.asterisk.org/r/1738/

(closes issue ASTERISK-19231)
(closes issue ASTERISK-19361)
Reported by: Thomas Arimont, Jamuel Starkey
Tested by: Thomas Arimont, Jamuel Starkey
Patches: sip_show_peers_2012_02_16.diff uploaded by mjordan (license 6283)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@356214 65c4cc65-6c06-0410-ace0-fbb531ad65f3
channels/chan_sip.c