diff options
-rw-r--r-- | include/asterisk/utils.h | 9 | ||||
-rw-r--r-- | main/channel.c | 15 | ||||
-rw-r--r-- | main/iostream.c | 10 | ||||
-rw-r--r-- | main/libasteriskssl.c | 4 | ||||
-rw-r--r-- | main/tcptls.c | 2 | ||||
-rw-r--r-- | main/utils.c | 12 | ||||
-rw-r--r-- | pbx/pbx_lua.c | 28 | ||||
-rw-r--r-- | res/res_calendar_caldav.c | 4 | ||||
-rw-r--r-- | res/res_pjsip_sdp_rtp.c | 7 | ||||
-rw-r--r-- | res/res_pjsip_t38.c | 7 |
10 files changed, 77 insertions, 21 deletions
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index 2378c6971..423d73b26 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -1126,4 +1126,13 @@ int ast_file_is_readable(const char *filename); */ int ast_compare_versions(const char *version1, const char *version2); +/* + * \brief Test that an OS supports IPv6 Networking. + * \since 13.14.0 + * + * \return True (non-zero) if the IPv6 supported. + * \return False (zero) if the OS doesn't support IPv6. + */ +int ast_check_ipv6(void); + #endif /* _ASTERISK_UTILS_H */ diff --git a/main/channel.c b/main/channel.c index bcfb8afa9..00cfa31aa 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1070,16 +1070,15 @@ void ast_channel_start_defer_frames(struct ast_channel *chan, int defer_hangups) void ast_channel_stop_defer_frames(struct ast_channel *chan) { + struct ast_frame *f; + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_DEFER_FRAMES); /* Move the deferred frames onto the channel read queue, ahead of other queued frames */ - ast_queue_frame_head(chan, AST_LIST_FIRST(ast_channel_deferred_readq(chan))); - /* ast_frfree will mosey down the list and free them all */ - if (!AST_LIST_EMPTY(ast_channel_deferred_readq(chan))) { - ast_frfree(AST_LIST_FIRST(ast_channel_deferred_readq(chan))); + while ((f = AST_LIST_REMOVE_HEAD(ast_channel_deferred_readq(chan), frame_list))) { + ast_queue_frame_head(chan, f); + ast_frfree(f); } - /* Reset the list to be empty */ - AST_LIST_HEAD_INIT_NOLOCK(ast_channel_deferred_readq(chan)); } static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after) @@ -3901,10 +3900,10 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) struct ast_frame *dup; dup = ast_frdup(f); - AST_LIST_INSERT_TAIL(ast_channel_deferred_readq(chan), dup, frame_list); + AST_LIST_INSERT_HEAD(ast_channel_deferred_readq(chan), dup, frame_list); } } else { - AST_LIST_INSERT_TAIL(ast_channel_deferred_readq(chan), f, frame_list); + AST_LIST_INSERT_HEAD(ast_channel_deferred_readq(chan), f, frame_list); AST_LIST_REMOVE_CURRENT(frame_list); } } diff --git a/main/iostream.c b/main/iostream.c index 008888142..a20a04896 100644 --- a/main/iostream.c +++ b/main/iostream.c @@ -462,9 +462,19 @@ int ast_iostream_close(struct ast_iostream *stream) SSL_get_error(stream->ssl, res)); } +#if defined(OPENSSL_API_COMPAT) && OPENSSL_API_COMPAT >= 0x10100000L + if (!SSL_is_server(stream->ssl)) { +#else if (!stream->ssl->server) { +#endif /* For client threads, ensure that the error stack is cleared */ +#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10000000L + ERR_remove_thread_state(NULL); +#else ERR_remove_state(0); +#endif /* OPENSSL_VERSION_NUMBER >= 0x10000000L */ +#endif /* !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L */ } SSL_free(stream->ssl); diff --git a/main/libasteriskssl.c b/main/libasteriskssl.c index 16a1aa739..9905b150c 100644 --- a/main/libasteriskssl.c +++ b/main/libasteriskssl.c @@ -65,13 +65,14 @@ static void ssl_lock(int mode, int n, const char *file, int line) return; } - if (mode & CRYPTO_LOCK) { + if (mode & 0x1) { ast_mutex_lock(&ssl_locks[n]); } else { ast_mutex_unlock(&ssl_locks[n]); } } +#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L int SSL_library_init(void) { #if defined(AST_DEVMODE) @@ -113,6 +114,7 @@ void ERR_free_strings(void) { /* we can't allow this to be called, ever */ } +#endif /* !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L */ #endif /* HAVE_OPENSSL */ diff --git a/main/tcptls.c b/main/tcptls.c index c8ebab434..6b040ae3e 100644 --- a/main/tcptls.c +++ b/main/tcptls.c @@ -310,7 +310,7 @@ static int __ssl_setup(struct ast_tls_config *cfg, int client) } if (client) { -#ifndef OPENSSL_NO_SSL2 +#if !defined(OPENSSL_NO_SSL2) && (OPENSSL_VERSION_NUMBER < 0x10100000L) if (ast_test_flag(&cfg->flags, AST_SSL_SSLV2_CLIENT)) { ast_log(LOG_WARNING, "Usage of SSLv2 is discouraged due to known vulnerabilities. Please use 'tlsv1' or leave the TLS method unspecified!\n"); cfg->ssl_ctx = SSL_CTX_new(SSLv2_client_method()); diff --git a/main/utils.c b/main/utils.c index 2c56af3cd..2033664b8 100644 --- a/main/utils.c +++ b/main/utils.c @@ -2391,6 +2391,18 @@ char *ast_utils_which(const char *binary, char *fullpath, size_t fullpath_size) return NULL; } +int ast_check_ipv6(void) +{ + int udp6_socket = socket(AF_INET6, SOCK_DGRAM, 0); + + if (udp6_socket < 0) { + return 0; + } + + close(udp6_socket); + return 1; +} + void DO_CRASH_NORETURN ast_do_crash(void) { #if defined(DO_CRASH) diff --git a/pbx/pbx_lua.c b/pbx/pbx_lua.c index 01f468de0..0754990d6 100644 --- a/pbx/pbx_lua.c +++ b/pbx/pbx_lua.c @@ -60,7 +60,7 @@ static char *registrar = "pbx_lua"; * applications might return */ #define LUA_GOTO_DETECTED 5 -static char *lua_read_extensions_file(lua_State *L, long *size); +static char *lua_read_extensions_file(lua_State *L, long *size, int *file_not_openable); static int lua_load_extensions(lua_State *L, struct ast_channel *chan); static int lua_reload_extensions(lua_State *L); static void lua_free_extensions(void); @@ -1070,12 +1070,13 @@ static int lua_extension_cmp(lua_State *L) * * \param L the lua_State to use * \param size a pointer to store the size of the buffer + * \param file_not_openable a pointer to store if config file could be opened * * \note The caller is expected to free the buffer at some point. * * \return a pointer to the buffer */ -static char *lua_read_extensions_file(lua_State *L, long *size) +static char *lua_read_extensions_file(lua_State *L, long *size, int *file_not_openable) { FILE *f; int error_func; @@ -1090,6 +1091,8 @@ static char *lua_read_extensions_file(lua_State *L, long *size) lua_pushstring(L, strerror(errno)); lua_concat(L, 4); + *file_not_openable = 1; + return NULL; } @@ -1199,10 +1202,14 @@ static int lua_reload_extensions(lua_State *L) { long size = 0; char *data = NULL; + int file_not_openable = 0; luaL_openlibs(L); - if (!(data = lua_read_extensions_file(L, &size))) { + if (!(data = lua_read_extensions_file(L, &size, &file_not_openable))) { + if (file_not_openable) { + return -1; + } return 1; } @@ -1621,17 +1628,24 @@ static struct ast_switch lua_switch = { static int load_or_reload_lua_stuff(void) { int res = AST_MODULE_LOAD_SUCCESS; + int loaded = 0; lua_State *L = luaL_newstate(); if (!L) { ast_log(LOG_ERROR, "Error allocating lua_State, no memory\n"); - return AST_MODULE_LOAD_DECLINE; + return AST_MODULE_LOAD_FAILURE; } - if (lua_reload_extensions(L)) { + loaded = lua_reload_extensions(L); + if (loaded) { const char *error = lua_tostring(L, -1); ast_log(LOG_ERROR, "Error loading extensions.lua: %s\n", error); - res = AST_MODULE_LOAD_DECLINE; + + if (loaded < 0) { + res = AST_MODULE_LOAD_DECLINE; + } else { + res = AST_MODULE_LOAD_FAILURE; + } } if (!res) { @@ -1664,7 +1678,7 @@ static int load_module(void) if (ast_register_switch(&lua_switch)) { ast_log(LOG_ERROR, "Unable to register LUA PBX switch\n"); - return AST_MODULE_LOAD_DECLINE; + return AST_MODULE_LOAD_FAILURE; } return AST_MODULE_LOAD_SUCCESS; diff --git a/res/res_calendar_caldav.c b/res/res_calendar_caldav.c index 11650375b..8a603cf47 100644 --- a/res/res_calendar_caldav.c +++ b/res/res_calendar_caldav.c @@ -480,7 +480,7 @@ static void handle_start_element(void *data, const xmlChar *fullname, const xmlC { struct xmlstate *state = data; - if (!xmlStrcasecmp(fullname, BAD_CAST "C:calendar-data")) { + if (!xmlStrcasecmp(fullname, BAD_CAST "C:calendar-data") || !xmlStrcasecmp(fullname, BAD_CAST "caldav:calendar-data")) { state->in_caldata = 1; ast_str_reset(state->cdata); } @@ -494,7 +494,7 @@ static void handle_end_element(void *data, const xmlChar *name) icalcomponent *iter; icalcomponent *comp; - if (xmlStrcasecmp(name, BAD_CAST "C:calendar-data")) { + if (xmlStrcasecmp(name, BAD_CAST "C:calendar-data") && xmlStrcasecmp(name, BAD_CAST "caldav:calendar-data")) { return; } diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 7fd4f9abc..4d6a1a168 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -38,6 +38,7 @@ #include <pjmedia.h> #include <pjlib.h> +#include "asterisk/utils.h" #include "asterisk/module.h" #include "asterisk/format.h" #include "asterisk/format_cap.h" @@ -1514,7 +1515,11 @@ static int load_module(void) { CHECK_PJSIP_SESSION_MODULE_LOADED(); - ast_sockaddr_parse(&address_rtp, "::", 0); + if (ast_check_ipv6()) { + ast_sockaddr_parse(&address_rtp, "::", 0); + } else { + ast_sockaddr_parse(&address_rtp, "0.0.0.0", 0); + } if (!(sched = ast_sched_context_create())) { ast_log(LOG_ERROR, "Unable to create scheduler context.\n"); diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index adc99c30d..79dc9c324 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -37,6 +37,7 @@ #include <pjmedia.h> #include <pjlib.h> +#include "asterisk/utils.h" #include "asterisk/module.h" #include "asterisk/udptl.h" #include "asterisk/netsock2.h" @@ -916,7 +917,11 @@ static int load_module(void) { CHECK_PJSIP_SESSION_MODULE_LOADED(); - ast_sockaddr_parse(&address, "::", 0); + if (ast_check_ipv6()) { + ast_sockaddr_parse(&address, "::", 0); + } else { + ast_sockaddr_parse(&address, "0.0.0.0", 0); + } if (ast_sip_session_register_supplement(&t38_supplement)) { ast_log(LOG_ERROR, "Unable to register T.38 session supplement\n"); |