summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/Makefile4
-rw-r--r--main/acl.c61
-rw-r--r--main/bridge_basic.c24
-rw-r--r--main/libasteriskssl.c2
4 files changed, 74 insertions, 17 deletions
diff --git a/main/Makefile b/main/Makefile
index efb0cafc9..4646c1b99 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -273,7 +273,7 @@ endif
$(ASTPJ_LIB).$(ASTPJ_SO_VERSION): _ASTLDFLAGS+=-Wl,-soname=$(ASTPJ_LIB).$(ASTPJ_SO_VERSION) $(PJ_LDFLAGS)
$(ASTPJ_LIB).$(ASTPJ_SO_VERSION): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskpj\" $(PJ_CFLAGS)
-$(ASTPJ_LIB).$(ASTPJ_SO_VERSION): LIBS+=$(PJPROJECT_LDLIBS) -lssl -lcrypto -luuid -lm -lpthread $(RT_LIB)
+$(ASTPJ_LIB).$(ASTPJ_SO_VERSION): LIBS+=$(PJPROJECT_LDLIBS) $(OPENSSL_LIB) $(UUID_LIB) -lm -lpthread $(RT_LIB)
ifeq ($(GNU_LD),1)
$(ASTPJ_LIB).$(ASTPJ_SO_VERSION): SO_SUPPRESS_SYMBOLS=-Wl,--version-script,libasteriskpj.exports,--warn-common
endif
@@ -298,7 +298,7 @@ ASTPJ_LIB:=libasteriskpj.dylib
# /lib or /usr/lib
$(ASTPJ_LIB): _ASTLDFLAGS+=-dynamiclib -install_name $(ASTLIBDIR)/$(ASTPJ_LIB) $(PJ_LDFLAGS)
$(ASTPJ_LIB): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskpj\" $(PJ_CFLAGS)
-$(ASTPJ_LIB): LIBS+=$(PJPROJECT_LIBS) -lssl -lcrypto -luuid -lm -lpthread $(RT_LIB)
+$(ASTPJ_LIB): LIBS+=$(PJPROJECT_LIBS) $(OPENSSL_LIB) $(UUID_LIB) -lm -lpthread $(RT_LIB)
$(ASTPJ_LIB): SOLINK=$(DYLINK)
# Special rules for building a shared library (not a dynamically loadable module)
diff --git a/main/acl.c b/main/acl.c
index 94a242af2..43035329c 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -283,6 +283,12 @@ struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original)
while (start) {
current = ast_duplicate_ha(start); /* Create copy of this object */
+ if (!current) {
+ ast_free_ha(ret);
+
+ return NULL;
+ }
+
if (prev) {
prev->next = current; /* Link previous to this object */
}
@@ -320,7 +326,7 @@ struct ast_acl_list *ast_duplicate_acl_list(struct ast_acl_list *original)
}
if (!(clone = ast_calloc(1, sizeof(*clone)))) {
- ast_log(LOG_WARNING, "Failed to allocate ast_acl_list struct while cloning an ACL\n");
+ ast_log(LOG_ERROR, "Failed to allocate ast_acl_list struct while cloning an ACL\n");
return NULL;
}
AST_LIST_HEAD_INIT(clone);
@@ -329,8 +335,10 @@ struct ast_acl_list *ast_duplicate_acl_list(struct ast_acl_list *original)
AST_LIST_TRAVERSE(original, current_cursor, list) {
if ((acl_new(&current_clone, current_cursor->name))) {
- ast_log(LOG_WARNING, "Failed to allocate ast_acl struct while cloning an ACL.");
- continue;
+ ast_log(LOG_ERROR, "Failed to allocate ast_acl struct while cloning an ACL.\n");
+ ast_free_acl_list(clone);
+ clone = NULL;
+ break;
}
/* Copy data from original ACL to clone ACL */
@@ -340,6 +348,15 @@ struct ast_acl_list *ast_duplicate_acl_list(struct ast_acl_list *original)
current_clone->is_realtime = current_cursor->is_realtime;
AST_LIST_INSERT_TAIL(clone, current_clone, list);
+
+ if (current_cursor->acl && !current_clone->acl) {
+ /* Deal with failure after adding to clone so we don't have to free
+ * current_clone separately. */
+ ast_log(LOG_ERROR, "Failed to duplicate HA list while cloning ACL.\n");
+ ast_free_acl_list(clone);
+ clone = NULL;
+ break;
+ }
}
AST_LIST_UNLOCK(original);
@@ -450,6 +467,8 @@ void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **
if (error) {
*error = 1;
}
+ AST_LIST_UNLOCK(working_list);
+ return;
}
// Need to INSERT the ACL at the head here.
AST_LIST_INSERT_HEAD(working_list, acl, list);
@@ -479,7 +498,8 @@ void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **
AST_LIST_TRAVERSE(working_list, current, list) {
if (!strcasecmp(current->name, tmp)) { /* ACL= */
/* Inclusion of the same ACL multiple times isn't a catastrophic error, but it will raise the error flag and skip the entry. */
- ast_log(LOG_ERROR, "Named ACL '%s' is already included in the ast_acl container.", tmp);
+ ast_log(LOG_ERROR, "Named ACL '%s' occurs multiple times in ACL definition. "
+ "Please update your ACL configuration.\n", tmp);
if (error) {
*error = 1;
}
@@ -538,6 +558,22 @@ int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
return 1;
}
+/*!
+ * \internal
+ * \brief Used by ast_append_ha to avoid ast_strdupa in a loop.
+ *
+ * \note This function is only called at debug level 3 and higher.
+ */
+static void debug_ha_sense_appended(struct ast_ha *ha)
+{
+ const char *parsed_mask = ast_strdupa(ast_sockaddr_stringify(&ha->netmask));
+
+ ast_log(LOG_DEBUG, "%s/%s sense %u appended to ACL\n",
+ ast_sockaddr_stringify(&ha->addr),
+ parsed_mask,
+ ha->sense);
+}
+
struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
{
struct ast_ha *ha;
@@ -547,7 +583,6 @@ struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha
char *address = NULL, *mask = NULL;
int addr_is_v4;
int allowing = strncasecmp(sense, "p", 1) ? AST_SENSE_DENY : AST_SENSE_ALLOW;
- const char *parsed_addr, *parsed_mask;
ret = path;
while (path) {
@@ -655,10 +690,9 @@ struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha
}
prev = ha;
- parsed_addr = ast_strdupa(ast_sockaddr_stringify(&ha->addr));
- parsed_mask = ast_strdupa(ast_sockaddr_stringify(&ha->netmask));
-
- ast_debug(3, "%s/%s sense %u appended to ACL\n", parsed_addr, parsed_mask, ha->sense);
+ if (DEBUG_ATLEAST(3)) {
+ debug_ha_sense_appended(ha);
+ }
}
return ret;
@@ -667,10 +701,11 @@ struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha
void ast_ha_join(const struct ast_ha *ha, struct ast_str **buf)
{
for (; ha; ha = ha->next) {
- const char *addr = ast_strdupa(ast_sockaddr_stringify_addr(&ha->addr));
- ast_str_append(buf, 0, "%s%s/%s",
- ha->sense == AST_SENSE_ALLOW ? "!" : "",
- addr, ast_sockaddr_stringify_addr(&ha->netmask));
+ ast_str_append(buf, 0, "%s%s/",
+ ha->sense == AST_SENSE_ALLOW ? "!" : "",
+ ast_sockaddr_stringify_addr(&ha->addr));
+ /* Separated to avoid duplicating stringified addresses. */
+ ast_str_append(buf, 0, "%s", ast_sockaddr_stringify_addr(&ha->netmask));
if (ha->next) {
ast_str_append(buf, 0, ",");
}
diff --git a/main/bridge_basic.c b/main/bridge_basic.c
index b24df0506..ef6d47cfe 100644
--- a/main/bridge_basic.c
+++ b/main/bridge_basic.c
@@ -1549,6 +1549,23 @@ static void stimulate_attended_transfer(struct attended_transfer_properties *pro
ao2_unlock(props);
}
+static void remove_attended_transfer_stimulus(struct attended_transfer_properties *props,
+ enum attended_transfer_stimulus stimulus)
+{
+ struct stimulus_list *list;
+
+ ao2_lock(props);
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&props->stimulus_queue, list, next) {
+ if (list->stimulus == stimulus) {
+ AST_LIST_REMOVE_CURRENT(next);
+ ast_free(list);
+ break;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ ao2_unlock(props);
+}
+
/*!
* \brief Get a desired transfer party for a bridge the transferer is not in.
*
@@ -2341,6 +2358,10 @@ static enum attended_transfer_state blond_nonfinal_exit(struct attended_transfer
return TRANSFER_RESUME;
case STIMULUS_TIMEOUT:
ast_softhangup(props->recall_target, AST_SOFTHANGUP_EXPLICIT);
+ /* It is possible before we hung them up that they queued up a recall target answer
+ * so we remove it if present as it should not exist.
+ */
+ remove_attended_transfer_stimulus(props, STIMULUS_RECALL_TARGET_ANSWER);
case STIMULUS_RECALL_TARGET_HANGUP:
props->recall_target = ast_channel_unref(props->recall_target);
return TRANSFER_RECALLING;
@@ -2806,7 +2827,8 @@ static struct ast_frame *transfer_target_framehook_cb(struct ast_channel *chan,
if (event == AST_FRAMEHOOK_EVENT_READ &&
frame && frame->frametype == AST_FRAME_CONTROL &&
- frame->subclass.integer == AST_CONTROL_ANSWER) {
+ frame->subclass.integer == AST_CONTROL_ANSWER &&
+ !ast_check_hangup(chan)) {
ast_debug(1, "Detected an answer for recall attempt on attended transfer %p\n", props);
if (props->superstate == SUPERSTATE_TRANSFER) {
diff --git a/main/libasteriskssl.c b/main/libasteriskssl.c
index a89f19125..41c6bcbb5 100644
--- a/main/libasteriskssl.c
+++ b/main/libasteriskssl.c
@@ -39,7 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#endif
#if defined(HAVE_OPENSSL) && \
- !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ (!defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER))
#include <dlfcn.h>