summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-08-21 18:49:23 +0000
committerRussell Bryant <russell@russellbryant.com>2007-08-21 18:49:23 +0000
commit8a2dd1d1450471bdcd9d2c24c3ac394a4fca0a4b (patch)
tree0e6bedd9c371070e124a5d633c062af881e04509 /channels
parent937d83f7e4c030ec5f219fdf20083eb5d625f71e (diff)
Merged revisions 80183 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r80183 | russell | 2007-08-21 13:42:15 -0500 (Tue, 21 Aug 2007) | 7 lines Don't record SIP dialog history if it's not turned on. Also, put an upper limit on how many history entires will be stored for each SIP dialog. It is currently set to 50, but can be increased if deemed necessary. (closes issue #10421, closes issue #10418, patches suggested by jmoldenhauer, patches updated by me) (Security implications documented in AST-2007-020) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@80184 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 0784fe90f..ba6b4ba9d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1114,6 +1114,7 @@ struct sip_pvt {
struct ast_rtp *trtp; /*!< Text RTP session */
struct sip_pkt *packets; /*!< Packets scheduled for re-transmission */
struct sip_history_head *history; /*!< History of this SIP dialog */
+ size_t history_entries; /*!< Number of entires in the history */
struct ast_variable *chanvars; /*!< Channel variables to set for inbound call */
struct sip_invite_param *options; /*!< Options for INVITE */
int autoframing; /*!< The number of Asters we group in a Pyroflax
@@ -1122,7 +1123,10 @@ struct sip_pvt {
you know more) */
};
-/*
+/*! Max entires in the history list for a sip_pvt */
+#define MAX_HISTORY_ENTRIES 50
+
+/*!
* Here we implement the container for dialogs (sip_pvt), defining
* generic wrapper functions to ease the transition from the current
* implementation (a single linked list) to a different container.
@@ -1130,7 +1134,6 @@ struct sip_pvt {
* the container and individual items, and functions to add/remove
* references to the individual items.
*/
-
static struct sip_pvt *dialoglist = NULL;
/*! \brief Protect the SIP dialog list (of sip_pvt's) */
@@ -2209,7 +2212,14 @@ static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
return;
}
memcpy(hist->event, buf, l);
+ if (p->history_entries == MAX_HISTORY_ENTRIES) {
+ struct sip_history *oldest;
+ oldest = AST_LIST_REMOVE_HEAD(p->history, list);
+ p->history_entries--;
+ ast_free(oldest);
+ }
AST_LIST_INSERT_TAIL(p->history, hist, list);
+ p->history_entries++;
}
/*! \brief Append to SIP dialog history with arg list */
@@ -2219,6 +2229,10 @@ static void append_history_full(struct sip_pvt *p, const char *fmt, ...)
if (!p)
return;
+
+ if (!p->do_history && !recordhistory && !dumphistory)
+ return;
+
va_start(ap, fmt);
append_history_va(p, fmt, ap);
va_end(ap);
@@ -3654,8 +3668,10 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
/* Clear history */
if (p->history) {
struct sip_history *hist;
- while( (hist = AST_LIST_REMOVE_HEAD(p->history, list)) )
+ while ( (hist = AST_LIST_REMOVE_HEAD(p->history, list)) ) {
ast_free(hist);
+ p->history_entries--;
+ }
ast_free(p->history);
p->history = NULL;
}