[asterisk-commits] oej: branch oej/pine-instance-uuid-1.8 r410448 - in /team/oej/pine-instance-u...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 11 07:28:34 CDT 2014
Author: oej
Date: Tue Mar 11 07:28:28 2014
New Revision: 410448
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410448
Log:
Reset stuff
Modified:
team/oej/pine-instance-uuid-1.8/ (props changed)
team/oej/pine-instance-uuid-1.8/channels/chan_sip.c
team/oej/pine-instance-uuid-1.8/configure.ac
team/oej/pine-instance-uuid-1.8/include/asterisk/autoconfig.h.in
team/oej/pine-instance-uuid-1.8/main/config.c
team/oej/pine-instance-uuid-1.8/main/http.c
team/oej/pine-instance-uuid-1.8/res/res_musiconhold.c
Propchange: team/oej/pine-instance-uuid-1.8/
------------------------------------------------------------------------------
automerge = Is-there-life-off-net?
Propchange: team/oej/pine-instance-uuid-1.8/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Mar 11 07:28:28 2014
@@ -1,1 +1,1 @@
-/branches/1.8:1-409810
+/branches/1.8:1-410447
Modified: team/oej/pine-instance-uuid-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-instance-uuid-1.8/channels/chan_sip.c?view=diff&rev=410448&r1=410447&r2=410448
==============================================================================
--- team/oej/pine-instance-uuid-1.8/channels/chan_sip.c (original)
+++ team/oej/pine-instance-uuid-1.8/channels/chan_sip.c Tue Mar 11 07:28:28 2014
@@ -17724,13 +17724,15 @@
*/
static void initiate_sip_instance(void)
{
- if (!ast_db_get("SIP", "instanceid", &sip_cfg.instance_id, sizeof(sip_cfg.instance_id))) {
+ char *uuid = &sip_cfg.instance.id;
+
+ if (!ast_db_get("SIP", "instanceid", uuid, sizeof(sip_cfg.instance_id))) {
/* We loaded instance ID from astdb. All good */
return;
}
/* Create UUID, store it */
- ast_uuid_generate_str(&sip_cfg.instance_id, sizeof(sip_cfg.instance_id));
- ast_db_put("SIP", "instanceid", &sip_cfg.instance_id);
+ ast_uuid_generate_str(uuid, sizeof(sip_cfg.instance_id));
+ ast_db_put("SIP", "instanceid", uuid);
return;
}
@@ -23054,6 +23056,145 @@
return 0;
}
+/*
+ * \internal \brief Check Session Timers for an INVITE request
+ *
+ * \retval 0 ok
+ * \retval -1 failure
+ */
+static int handle_request_invite_st(struct sip_pvt *p, struct sip_request *req,
+ const char *required, int reinvite)
+{
+ const char *p_uac_se_hdr; /* UAC's Session-Expires header string */
+ const char *p_uac_min_se; /* UAC's requested Min-SE interval (char string) */
+ int uac_max_se = -1; /* UAC's Session-Expires in integer format */
+ int uac_min_se = -1; /* UAC's Min-SE in integer format */
+ int st_active = FALSE; /* Session-Timer on/off boolean */
+ int st_interval = 0; /* Session-Timer negotiated refresh interval */
+ enum st_refresher tmp_st_ref = SESSION_TIMER_REFRESHER_AUTO; /* Session-Timer refresher */
+ int dlg_min_se = -1;
+ int dlg_max_se = global_max_se;
+ int rtn;
+
+ /* Session-Timers */
+ if ((p->sipoptions & SIP_OPT_TIMER)) {
+ enum st_refresher_param st_ref_param = SESSION_TIMER_REFRESHER_PARAM_UNKNOWN;
+
+ /* The UAC has requested session-timers for this session. Negotiate
+ the session refresh interval and who will be the refresher */
+ ast_debug(2, "Incoming INVITE with 'timer' option supported\n");
+
+ /* Allocate Session-Timers struct w/in the dialog */
+ if (!p->stimer) {
+ sip_st_alloc(p);
+ }
+
+ /* Parse the Session-Expires header */
+ p_uac_se_hdr = get_header(req, "Session-Expires");
+ if (!ast_strlen_zero(p_uac_se_hdr)) {
+ ast_debug(2, "INVITE also has \"Session-Expires\" header.\n");
+ rtn = parse_session_expires(p_uac_se_hdr, &uac_max_se, &st_ref_param);
+ tmp_st_ref = (st_ref_param == SESSION_TIMER_REFRESHER_PARAM_UAC) ? SESSION_TIMER_REFRESHER_THEM : SESSION_TIMER_REFRESHER_US;
+ if (rtn != 0) {
+ transmit_response_reliable(p, "400 Session-Expires Invalid Syntax", req);
+ return -1;
+ }
+ }
+
+ /* Parse the Min-SE header */
+ p_uac_min_se = get_header(req, "Min-SE");
+ if (!ast_strlen_zero(p_uac_min_se)) {
+ ast_debug(2, "INVITE also has \"Min-SE\" header.\n");
+ rtn = parse_minse(p_uac_min_se, &uac_min_se);
+ if (rtn != 0) {
+ transmit_response_reliable(p, "400 Min-SE Invalid Syntax", req);
+ return -1;
+ }
+ }
+
+ dlg_min_se = st_get_se(p, FALSE);
+ switch (st_get_mode(p, 1)) {
+ case SESSION_TIMER_MODE_ACCEPT:
+ case SESSION_TIMER_MODE_ORIGINATE:
+ if (uac_max_se > 0 && uac_max_se < dlg_min_se) {
+ transmit_response_with_minse(p, "422 Session Interval Too Small", req, dlg_min_se);
+ return -1;
+ }
+
+ p->stimer->st_active_peer_ua = TRUE;
+ st_active = TRUE;
+ if (st_ref_param == SESSION_TIMER_REFRESHER_PARAM_UNKNOWN) {
+ tmp_st_ref = st_get_refresher(p);
+ }
+
+ dlg_max_se = st_get_se(p, TRUE);
+ if (uac_max_se > 0) {
+ if (dlg_max_se >= uac_min_se) {
+ st_interval = (uac_max_se < dlg_max_se) ? uac_max_se : dlg_max_se;
+ } else {
+ st_interval = uac_max_se;
+ }
+ } else if (uac_min_se > 0) {
+ st_interval = MAX(dlg_max_se, uac_min_se);
+ } else {
+ st_interval = dlg_max_se;
+ }
+ break;
+
+ case SESSION_TIMER_MODE_REFUSE:
+ if (p->reqsipoptions & SIP_OPT_TIMER) {
+ transmit_response_with_unsupported(p, "420 Option Disabled", req, required);
+ ast_log(LOG_WARNING, "Received SIP INVITE with supported but disabled option: %s\n", required);
+ return -1;
+ }
+ break;
+
+ default:
+ ast_log(LOG_ERROR, "Internal Error %d at %s:%d\n", st_get_mode(p, 1), __FILE__, __LINE__);
+ break;
+ }
+ } else {
+ /* The UAC did not request session-timers. Asterisk (UAS), will now decide
+ (based on session-timer-mode in sip.conf) whether to run session-timers for
+ this session or not. */
+ switch (st_get_mode(p, 1)) {
+ case SESSION_TIMER_MODE_ORIGINATE:
+ st_active = TRUE;
+ st_interval = st_get_se(p, TRUE);
+ tmp_st_ref = SESSION_TIMER_REFRESHER_US;
+ p->stimer->st_active_peer_ua = (p->sipoptions & SIP_OPT_TIMER) ? TRUE : FALSE;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (reinvite == 0) {
+ /* Session-Timers: Start session refresh timer based on negotiation/config */
+ if (st_active == TRUE) {
+ p->stimer->st_active = TRUE;
+ p->stimer->st_interval = st_interval;
+ p->stimer->st_ref = tmp_st_ref;
+ }
+ } else {
+ if (p->stimer->st_active == TRUE) {
+ /* Session-Timers: A re-invite request sent within a dialog will serve as
+ a refresh request, no matter whether the re-invite was sent for refreshing
+ the session or modifying it.*/
+ ast_debug (2, "Restarting session-timers on a refresh - %s\n", p->callid);
+
+ /* The UAC may be adjusting the session-timers mid-session */
+ if (st_interval > 0) {
+ p->stimer->st_interval = st_interval;
+ p->stimer->st_ref = tmp_st_ref;
+ }
+ }
+ }
+
+ return 0;
+}
+
/*!
* \brief Handle incoming INVITE request
* \note If the INVITE has a Replaces header, it is part of an
@@ -23073,19 +23214,9 @@
struct ast_channel *c = NULL; /* New channel */
struct sip_peer *authpeer = NULL; /* Matching Peer */
int reinvite = 0;
- int rtn;
struct ast_party_redirecting redirecting;
struct ast_set_party_redirecting update_redirecting;
- const char *p_uac_se_hdr; /* UAC's Session-Expires header string */
- const char *p_uac_min_se; /* UAC's requested Min-SE interval (char string) */
- int uac_max_se = -1; /* UAC's Session-Expires in integer format */
- int uac_min_se = -1; /* UAC's Min-SE in integer format */
- int st_active = FALSE; /* Session-Timer on/off boolean */
- int st_interval = 0; /* Session-Timer negotiated refresh interval */
- enum st_refresher tmp_st_ref = SESSION_TIMER_REFRESHER_AUTO; /* Session-Timer refresher */
- int dlg_min_se = -1;
- int dlg_max_se = global_max_se;
struct {
char exten[AST_MAX_EXTENSION];
char context[AST_MAX_CONTEXT];
@@ -23565,6 +23696,14 @@
/* Initialize our tag */
make_our_tag(p);
+
+ if (handle_request_invite_st(p, req, required, reinvite)) {
+ p->invitestate = INV_COMPLETED;
+ sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ res = -1;
+ goto request_invite_cleanup;
+ }
+
/* First invitation - create the channel. Allocation
* failures are handled below. */
c = sip_new(p, AST_STATE_DOWN, S_OR(p->peername, NULL), NULL);
@@ -23597,6 +23736,16 @@
}
if (!req->ignore)
reinvite = 1;
+
+ if (handle_request_invite_st(p, req, required, reinvite)) {
+ p->invitestate = INV_COMPLETED;
+ if (!p->lastinvite) {
+ sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ }
+ res = -1;
+ goto request_invite_cleanup;
+ }
+
c = p->owner;
change_redirecting_information(p, req, &redirecting, &update_redirecting, FALSE); /*Will return immediately if no Diversion header is present */
if (c) {
@@ -23605,140 +23754,10 @@
ast_party_redirecting_free(&redirecting);
}
- /* Session-Timers */
- if ((p->sipoptions & SIP_OPT_TIMER)) {
- enum st_refresher_param st_ref_param = SESSION_TIMER_REFRESHER_PARAM_UNKNOWN;
-
- /* The UAC has requested session-timers for this session. Negotiate
- the session refresh interval and who will be the refresher */
- ast_debug(2, "Incoming INVITE with 'timer' option supported\n");
-
- /* Allocate Session-Timers struct w/in the dialog */
- if (!p->stimer)
- sip_st_alloc(p);
-
- /* Parse the Session-Expires header */
- p_uac_se_hdr = get_header(req, "Session-Expires");
- if (!ast_strlen_zero(p_uac_se_hdr)) {
- ast_debug(2, "INVITE also has \"Session-Expires\" header.\n");
- rtn = parse_session_expires(p_uac_se_hdr, &uac_max_se, &st_ref_param);
- tmp_st_ref = (st_ref_param == SESSION_TIMER_REFRESHER_PARAM_UAC) ? SESSION_TIMER_REFRESHER_THEM : SESSION_TIMER_REFRESHER_US;
- if (rtn != 0) {
- transmit_response_reliable(p, "400 Session-Expires Invalid Syntax", req);
- p->invitestate = INV_COMPLETED;
- if (!p->lastinvite) {
- sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- }
- res = -1;
- goto request_invite_cleanup;
- }
- }
-
- /* Parse the Min-SE header */
- p_uac_min_se = get_header(req, "Min-SE");
- if (!ast_strlen_zero(p_uac_min_se)) {
- ast_debug(2, "INVITE also has \"Min-SE\" header.\n");
- rtn = parse_minse(p_uac_min_se, &uac_min_se);
- if (rtn != 0) {
- transmit_response_reliable(p, "400 Min-SE Invalid Syntax", req);
- p->invitestate = INV_COMPLETED;
- if (!p->lastinvite) {
- sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- }
- res = -1;
- goto request_invite_cleanup;
- }
- }
-
- dlg_min_se = st_get_se(p, FALSE);
- switch (st_get_mode(p, 1)) {
- case SESSION_TIMER_MODE_ACCEPT:
- case SESSION_TIMER_MODE_ORIGINATE:
- if (uac_max_se > 0 && uac_max_se < dlg_min_se) {
- transmit_response_with_minse(p, "422 Session Interval Too Small", req, dlg_min_se);
- p->invitestate = INV_COMPLETED;
- if (!p->lastinvite) {
- sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- }
- res = -1;
- goto request_invite_cleanup;
- }
-
- p->stimer->st_active_peer_ua = TRUE;
- st_active = TRUE;
- if (st_ref_param == SESSION_TIMER_REFRESHER_PARAM_UNKNOWN) {
- tmp_st_ref = st_get_refresher(p);
- }
-
- dlg_max_se = st_get_se(p, TRUE);
- if (uac_max_se > 0) {
- if (dlg_max_se >= uac_min_se) {
- st_interval = (uac_max_se < dlg_max_se) ? uac_max_se : dlg_max_se;
- } else {
- st_interval = uac_max_se;
- }
- } else if (uac_min_se > 0) {
- st_interval = MAX(dlg_max_se, uac_min_se);
- } else {
- st_interval = dlg_max_se;
- }
- break;
-
- case SESSION_TIMER_MODE_REFUSE:
- if (p->reqsipoptions & SIP_OPT_TIMER) {
- transmit_response_with_unsupported(p, "420 Option Disabled", req, required);
- ast_log(LOG_WARNING, "Received SIP INVITE with supported but disabled option: %s\n", required);
- p->invitestate = INV_COMPLETED;
- if (!p->lastinvite) {
- sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- }
- res = -1;
- goto request_invite_cleanup;
- }
- break;
-
- default:
- ast_log(LOG_ERROR, "Internal Error %d at %s:%d\n", st_get_mode(p, 1), __FILE__, __LINE__);
- break;
- }
- } else {
- /* The UAC did not request session-timers. Asterisk (UAS), will now decide
- (based on session-timer-mode in sip.conf) whether to run session-timers for
- this session or not. */
- switch (st_get_mode(p, 1)) {
- case SESSION_TIMER_MODE_ORIGINATE:
- st_active = TRUE;
- st_interval = st_get_se(p, TRUE);
- tmp_st_ref = SESSION_TIMER_REFRESHER_US;
- p->stimer->st_active_peer_ua = (p->sipoptions & SIP_OPT_TIMER) ? TRUE : FALSE;
- break;
-
- default:
- break;
- }
- }
-
- if (reinvite == 0) {
- /* Session-Timers: Start session refresh timer based on negotiation/config */
- if (st_active == TRUE) {
- p->stimer->st_active = TRUE;
- p->stimer->st_interval = st_interval;
- p->stimer->st_ref = tmp_st_ref;
+ if (p->stimer->st_active == TRUE) {
+ if (reinvite == 0) {
start_session_timer(p);
- }
- } else {
- if (p->stimer->st_active == TRUE) {
- /* Session-Timers: A re-invite request sent within a dialog will serve as
- a refresh request, no matter whether the re-invite was sent for refreshing
- the session or modifying it.*/
- ast_debug (2, "Restarting session-timers on a refresh - %s\n", p->callid);
-
- /* The UAC may be adjusting the session-timers mid-session */
- if (st_interval > 0) {
- p->stimer->st_interval = st_interval;
- p->stimer->st_ref = tmp_st_ref;
- }
-
+ } else {
restart_session_timer(p);
}
}
@@ -28731,21 +28750,26 @@
peer->socket.port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
}
- if (!sip_cfg.ignore_regexpire && peer->host_dynamic && realtime) {
- time_t nowtime = time(NULL);
-
- if ((nowtime - regseconds) > 0) {
- destroy_association(peer);
- memset(&peer->addr, 0, sizeof(peer->addr));
- peer->lastms = -1;
- ast_debug(1, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
- }
- }
-
- /* Startup regular pokes */
- if (!devstate_only && realtime && peer->lastms > 0) {
- ref_peer(peer, "schedule qualify");
- sip_poke_peer(peer, 0);
+ if (realtime) {
+ int enablepoke = 1;
+
+ if (!sip_cfg.ignore_regexpire && peer->host_dynamic) {
+ time_t nowtime = time(NULL);
+
+ if ((nowtime - regseconds) > 0) {
+ destroy_association(peer);
+ memset(&peer->addr, 0, sizeof(peer->addr));
+ peer->lastms = -1;
+ enablepoke = 0;
+ ast_debug(1, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ }
+ }
+
+ /* Startup regular pokes */
+ if (!devstate_only && enablepoke) {
+ ref_peer(peer, "schedule qualify");
+ sip_poke_peer(peer, 0);
+ }
}
if (ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
@@ -32085,12 +32109,16 @@
ast_mutex_lock(&monlock);
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {
- pthread_cancel(monitor_thread);
- pthread_kill(monitor_thread, SIGURG);
- pthread_join(monitor_thread, NULL);
- }
- monitor_thread = AST_PTHREADT_STOP;
- ast_mutex_unlock(&monlock);
+ pthread_t th = monitor_thread;
+ monitor_thread = AST_PTHREADT_STOP;
+ pthread_cancel(th);
+ pthread_kill(th, SIGURG);
+ ast_mutex_unlock(&monlock);
+ pthread_join(th, NULL);
+ } else {
+ monitor_thread = AST_PTHREADT_STOP;
+ ast_mutex_unlock(&monlock);
+ }
/* Destroy all the dialogs and free their memory */
i = ao2_iterator_init(dialogs, 0);
Modified: team/oej/pine-instance-uuid-1.8/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-instance-uuid-1.8/configure.ac?view=diff&rev=410448&r1=410447&r2=410448
==============================================================================
--- team/oej/pine-instance-uuid-1.8/configure.ac (original)
+++ team/oej/pine-instance-uuid-1.8/configure.ac Tue Mar 11 07:28:28 2014
@@ -544,6 +544,12 @@
AC_STRUCT_TM
AC_C_VOLATILE
AC_CHECK_TYPES([ptrdiff_t])
+stat_nsec_found=no
+AC_CHECK_MEMBERS([struct stat.st_mtim, struct stat.st_mtimensec, struct stat.st_mtimespec], [stat_nsec_found=yes], [], [[#include <sys/stat.h>]])
+
+if test "${stat_nsec_found}" != yes; then
+ AC_MSG_WARN(Cannot determine nanosecond field of struct stat)
+fi
# Checks for library functions.
AC_FUNC_CHOWN
Modified: team/oej/pine-instance-uuid-1.8/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-instance-uuid-1.8/include/asterisk/autoconfig.h.in?view=diff&rev=410448&r1=410447&r2=410448
==============================================================================
--- team/oej/pine-instance-uuid-1.8/include/asterisk/autoconfig.h.in (original)
+++ team/oej/pine-instance-uuid-1.8/include/asterisk/autoconfig.h.in Tue Mar 11 07:28:28 2014
@@ -843,7 +843,16 @@
/* Define to 1 if `st_blksize' is member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
-/* Define to 1 if `cr_uid' is member of `struct ucred'. */
+/* Define to 1 if `st_mtim' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_MTIM
+
+/* Define to 1 if `st_mtimensec' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_MTIMENSEC
+
+/* Define to 1 if `st_mtimespec' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_MTIMESPEC
+
+/* Define to 1 if `cr_uid' is a member of `struct ucred'. */
#undef HAVE_STRUCT_UCRED_CR_UID
/* Define to 1 if `uid' is member of `struct ucred'. */
Modified: team/oej/pine-instance-uuid-1.8/main/config.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-instance-uuid-1.8/main/config.c?view=diff&rev=410448&r1=410447&r2=410448
==============================================================================
--- team/oej/pine-instance-uuid-1.8/main/config.c (original)
+++ team/oej/pine-instance-uuid-1.8/main/config.c Tue Mar 11 07:28:28 2014
@@ -1092,10 +1092,14 @@
static void cfmstat_save(struct cache_file_mtime *cfmtime, struct stat *statbuf)
{
cfmtime->stat_size = statbuf->st_size;
-#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || (defined(_POSIX_C_SOURCE) && 200809L <= _POSIX_C_SOURCE) || (defined(_XOPEN_SOURCE) && 700 <= _XOPEN_SOURCE)
+#if defined(HAVE_STRUCT_STAT_ST_MTIM)
cfmtime->stat_mtime_nsec = statbuf->st_mtim.tv_nsec;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
+ cfmtime->stat_mtime_nsec = statbuf->st_mtimensec;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ cfmtime->stat_mtime_nsec = statbuf->st_mtimespec.tv_nsec;
#else
- cfmtime->stat_mtime_nsec = statbuf->st_mtimensec;
+ cfmtime->stat_mtime_nsec = 0;
#endif
cfmtime->stat_mtime = statbuf->st_mtime;
}
@@ -1142,7 +1146,7 @@
AST_LIST_INSERT_SORTALPHA(&cfmtime_head, cfmtime, list, filename);
}
- if (!stat(configfile, &statbuf)) {
+ if (stat(configfile, &statbuf)) {
cfmstat_clear(cfmtime);
} else {
cfmstat_save(cfmtime, &statbuf);
Modified: team/oej/pine-instance-uuid-1.8/main/http.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-instance-uuid-1.8/main/http.c?view=diff&rev=410448&r1=410447&r2=410448
==============================================================================
--- team/oej/pine-instance-uuid-1.8/main/http.c (original)
+++ team/oej/pine-instance-uuid-1.8/main/http.c Tue Mar 11 07:28:28 2014
@@ -187,9 +187,7 @@
break;
}
}
- if (cookies) {
- ast_variables_destroy(cookies);
- }
+ ast_variables_destroy(cookies);
return mngid;
}
@@ -824,12 +822,13 @@
}*/
#endif /* DO_SSL */
-static struct ast_variable *parse_cookies(char *cookies)
-{
+static struct ast_variable *parse_cookies(const char *cookies)
+{
+ char *parse = ast_strdupa(cookies);
char *cur;
struct ast_variable *vars = NULL, *var;
- while ((cur = strsep(&cookies, ";"))) {
+ while ((cur = strsep(&parse, ";"))) {
char *name, *val;
name = val = cur;
@@ -859,21 +858,19 @@
/* get cookie from Request headers */
struct ast_variable *ast_http_get_cookies(struct ast_variable *headers)
{
- struct ast_variable *v, *cookies=NULL;
+ struct ast_variable *v, *cookies = NULL;
for (v = headers; v; v = v->next) {
if (!strcasecmp(v->name, "Cookie")) {
- char *tmp = ast_strdupa(v->value);
- if (cookies) {
- ast_variables_destroy(cookies);
- }
-
- cookies = parse_cookies(tmp);
+ ast_variables_destroy(cookies);
+ cookies = parse_cookies(v->value);
}
}
return cookies;
}
+/*! Limit the number of request headers in case the sender is being ridiculous. */
+#define MAX_HTTP_REQUEST_HEADERS 100
static void *httpd_helper_thread(void *data)
{
@@ -884,6 +881,7 @@
struct ast_variable *tail = headers;
char *uri, *method;
enum ast_http_method http_method = AST_HTTP_UNKNOWN;
+ int remaining_headers;
if (ast_atomic_fetchadd_int(&session_count, +1) >= session_limit) {
goto done;
@@ -918,9 +916,13 @@
if (*c) {
*c = '\0';
}
+ } else {
+ ast_http_error(ser, 400, "Bad Request", "Invalid Request");
+ goto done;
}
/* process "Request Headers" lines */
+ remaining_headers = MAX_HTTP_REQUEST_HEADERS;
while (fgets(header_line, sizeof(header_line), ser->f)) {
char *name, *value;
@@ -943,6 +945,11 @@
ast_trim_blanks(name);
+ if (!remaining_headers--) {
+ /* Too many headers. */
+ ast_http_error(ser, 413, "Request Entity Too Large", "Too many headers");
+ goto done;
+ }
if (!headers) {
headers = ast_variable_new(name, value, __FILE__);
tail = headers;
@@ -950,11 +957,17 @@
tail->next = ast_variable_new(name, value, __FILE__);
tail = tail->next;
}
- }
-
- if (!*uri) {
- ast_http_error(ser, 400, "Bad Request", "Invalid Request");
- goto done;
+ if (!tail) {
+ /*
+ * Variable allocation failure.
+ * Try to make some room.
+ */
+ ast_variables_destroy(headers);
+ headers = NULL;
+
+ ast_http_error(ser, 500, "Server Error", "Out of memory");
+ goto done;
+ }
}
handle_uri(ser, uri, http_method, headers);
@@ -963,9 +976,7 @@
ast_atomic_fetchadd_int(&session_count, -1);
/* clean up all the header information */
- if (headers) {
- ast_variables_destroy(headers);
- }
+ ast_variables_destroy(headers);
if (ser->f) {
fclose(ser->f);
Modified: team/oej/pine-instance-uuid-1.8/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pine-instance-uuid-1.8/res/res_musiconhold.c?view=diff&rev=410448&r1=410447&r2=410448
==============================================================================
--- team/oej/pine-instance-uuid-1.8/res/res_musiconhold.c (original)
+++ team/oej/pine-instance-uuid-1.8/res/res_musiconhold.c Tue Mar 11 07:28:28 2014
@@ -1431,12 +1431,6 @@
if (state && state->class) {
/* Class already exist for this channel */
ast_log(LOG_NOTICE, "This channel already has a MOH class attached (%s)!\n", state->class->name);
- if (state->class->realtime && !ast_test_flag(global_flags, MOH_CACHERTCLASSES) && !strcasecmp(mohclass->name, state->class->name)) {
- /* we found RT class with the same name, seems like we should continue playing existing one */
- /* XXX This code is impossible to reach */
- mohclass = mohclass_unref(mohclass, "unreffing potential mohclass (channel already has a class)");
- mohclass = state->class;
- }
}
/* We don't want moh_register to unref the mohclass because we do it at the end of this function as well.
* If we allowed moh_register to unref the mohclass,too, then the count would be off by one. The result would
@@ -1489,7 +1483,7 @@
if (state->class->realtime && !ast_test_flag(global_flags, MOH_CACHERTCLASSES) && !strcasecmp(mohclass->name, state->class->name)) {
/* we found RT class with the same name, seems like we should continue playing existing one */
mohclass = mohclass_unref(mohclass, "unreffing potential mohclass (channel already has one)");
- mohclass = state->class;
+ mohclass = mohclass_ref(state->class, "using existing class from state");
}
} else {
if (ast_pthread_create_background(&mohclass->thread, NULL, monmp3thread, mohclass)) {
More information about the asterisk-commits
mailing list