diff options
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | main/pbx.c | 55 | ||||
-rw-r--r-- | res/res_pjsip_endpoint_identifier_ip.c | 7 | ||||
-rw-r--r-- | res/res_pjsip_refer.c | 7 |
5 files changed, 52 insertions, 21 deletions
@@ -7901,7 +7901,7 @@ if test "${WGET}" != ":" ; then DOWNLOAD_TIMEOUT='--timeout=$1' else if test "${CURL}" != ":" ; then DOWNLOAD="${CURL} -O --progress-bar -w \"%{url_effective}\n\"" - DOWNLOAD_TO_STDOUT="${CURL} -L --progress-bar" + DOWNLOAD_TO_STDOUT="${CURL} -Ls" DOWNLOAD_TIMEOUT='--max-time $(or $2,$1)' else # Extract the first word of "fetch", so it can be a program name with args. diff --git a/configure.ac b/configure.ac index 039648a43..12f4a34dd 100644 --- a/configure.ac +++ b/configure.ac @@ -319,7 +319,7 @@ if test "${WGET}" != ":" ; then DOWNLOAD_TIMEOUT='--timeout=$1' else if test "${CURL}" != ":" ; then DOWNLOAD="${CURL} -O --progress-bar -w \"%{url_effective}\n\"" - DOWNLOAD_TO_STDOUT="${CURL} -L --progress-bar" + DOWNLOAD_TO_STDOUT="${CURL} -Ls" DOWNLOAD_TIMEOUT='--max-time $(or $2,$1)' else AC_PATH_PROG([FETCH], [fetch], [:]) diff --git a/main/pbx.c b/main/pbx.c index d648084d7..df99940ba 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -616,7 +616,7 @@ static int ast_add_extension2_lockopt(struct ast_context *con, static struct ast_context *find_context_locked(const char *context); static struct ast_context *find_context(const char *context); static void get_device_state_causing_channels(struct ao2_container *c); -static int ext_strncpy(char *dst, const char *src, int len, int nofluff); +static unsigned int ext_strncpy(char *dst, const char *src, size_t dst_size, int nofluff); /*! * \internal @@ -6907,32 +6907,51 @@ int ast_async_goto_by_name(const char *channame, const char *context, const char return res; } -/*! \brief copy a string skipping whitespace and dashes */ -static int ext_strncpy(char *dst, const char *src, int len, int nofluff) +/*! + * \internal + * \brief Copy a string skipping whitespace and optionally dashes. + * + * \param dst Destination buffer to copy src string. + * \param src Null terminated string to copy. + * \param dst_size Number of bytes in the dst buffer. + * \param nofluf Nonzero if '-' chars are not copied. + * + * \return Number of bytes written to dst including null terminator. + */ +static unsigned int ext_strncpy(char *dst, const char *src, size_t dst_size, int nofluff) { - int count = 0; - int insquares = 0; + unsigned int count; + unsigned int insquares; + unsigned int is_pattern; - while (*src && (count < len - 1)) { + if (!dst_size--) { + /* There really is no dst buffer */ + return 0; + } + + count = 0; + insquares = 0; + is_pattern = *src == '_'; + while (*src && count < dst_size) { if (*src == '[') { - insquares = 1; + if (is_pattern) { + insquares = 1; + } } else if (*src == ']') { insquares = 0; } else if (*src == ' ' && !insquares) { - src++; + ++src; continue; } else if (*src == '-' && !insquares && nofluff) { - src++; + ++src; continue; } - *dst = *src; - dst++; - src++; - count++; + *dst++ = *src++; + ++count; } *dst = '\0'; - return count; + return count + 1; } /*! @@ -7246,10 +7265,10 @@ static int ast_add_extension2_lockopt(struct ast_context *con, p += strlen(label) + 1; } tmp->name = p; - p += ext_strncpy(p, extension, strlen(extension) + 1, 0) + 1; + p += ext_strncpy(p, extension, strlen(extension) + 1, 0); if (exten_fluff) { tmp->exten = p; - p += ext_strncpy(p, extension, strlen(extension) + 1, 1) + 1; + p += ext_strncpy(p, extension, strlen(extension) + 1 - exten_fluff, 1); } else { /* no fluff, we don't need a copy. */ tmp->exten = tmp->name; @@ -7259,10 +7278,10 @@ static int ast_add_extension2_lockopt(struct ast_context *con, /* Blank callerid and NULL callerid are two SEPARATE things. Do NOT confuse the two!!! */ if (callerid) { - p += ext_strncpy(p, callerid, strlen(callerid) + 1, 0) + 1; + p += ext_strncpy(p, callerid, strlen(callerid) + 1, 0); if (callerid_fluff) { tmp->cidmatch = p; - p += ext_strncpy(p, callerid, strlen(callerid) + 1, 1) + 1; + p += ext_strncpy(p, callerid, strlen(callerid) + 1 - callerid_fluff, 1); } tmp->matchcid = AST_EXT_MATCHCID_ON; } else { diff --git a/res/res_pjsip_endpoint_identifier_ip.c b/res/res_pjsip_endpoint_identifier_ip.c index 1bd7e892d..f935882c9 100644 --- a/res/res_pjsip_endpoint_identifier_ip.c +++ b/res/res_pjsip_endpoint_identifier_ip.c @@ -140,9 +140,14 @@ static int header_identify_match_check(void *obj, void *arg, int flags) pjsip_generic_string_hdr *header; pj_str_t pj_header_name; pj_str_t pj_header_value; - char *c_header = ast_strdupa(identify->match_header); + char *c_header; char *c_value; + if (ast_strlen_zero(identify->match_header)) { + return 0; + } + + c_header = ast_strdupa(identify->match_header); c_value = strchr(c_header, ':'); if (!c_value) { ast_log(LOG_WARNING, "Identify '%s' has invalid header_match: No ':' separator found!\n", diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c index d52a922fd..db5061249 100644 --- a/res/res_pjsip_refer.c +++ b/res/res_pjsip_refer.c @@ -822,6 +822,13 @@ static int refer_incoming_blind_request(struct ast_sip_session *session, pjsip_r */ AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(exten); + /* Uri without exten */ + if (ast_strlen_zero(exten)) { + ast_copy_string(exten, "s", sizeof(exten)); + ast_debug(3, "Channel '%s' from endpoint '%s' attempted blind transfer to a target without extension. Target was set to 's@%s'\n", + ast_channel_name(session->channel), ast_sorcery_object_get_id(session->endpoint), context); + } + if (!ast_exists_extension(NULL, context, exten, 1, NULL)) { ast_log(LOG_ERROR, "Channel '%s' from endpoint '%s' attempted blind transfer to '%s@%s' but target does not exist\n", ast_channel_name(session->channel), ast_sorcery_object_get_id(session->endpoint), exten, context); |