diff options
-rw-r--r-- | contrib/scripts/sip_to_pjsip/astconfigparser.py | 24 | ||||
-rw-r--r-- | funcs/func_cdr.c | 10 | ||||
-rw-r--r-- | main/rtp_engine.c | 14 |
3 files changed, 37 insertions, 11 deletions
diff --git a/contrib/scripts/sip_to_pjsip/astconfigparser.py b/contrib/scripts/sip_to_pjsip/astconfigparser.py index b207b0d7c..46f4fb484 100644 --- a/contrib/scripts/sip_to_pjsip/astconfigparser.py +++ b/contrib/scripts/sip_to_pjsip/astconfigparser.py @@ -1,3 +1,10 @@ +""" +Copyright (C) 2016, Digium, Inc. + +This program is free software, distributed under the terms of +the GNU General Public License Version 2. +""" + import re import itertools @@ -44,6 +51,12 @@ class Section(MultiOrderedDict): """ return cmp(self.id, other.id) + def __eq__(self, other): + """ + Use self.id as means of determining equality + """ + return self.id == other.id + def get(self, key, from_self=True, from_templates=True, from_defaults=True): """ @@ -184,9 +197,14 @@ def remove_comment(line, is_comment): # otherwise it was an embedded comment so combine return ''.join([part[0].strip(), ' ', line]).rstrip(), False - # check for eol comment - return line.partition(COMMENT)[0].strip(), False + # find the first occurence of a comment that is not escaped + match = re.match(r'.*?([^\\];)', line) + + if match: + # the end of where the real string is is where the comment starts + line = line[0:(match.end()-1)] + return line.replace("\\", "").strip(), False def try_include(line): """ @@ -224,7 +242,7 @@ def try_section(line): def try_option(line): """Parses the line as an option, returning the key/value pair.""" - data = re.split('=>?', line) + data = re.split('=>?', line, 1) # should split in two (key/val), but either way use first two elements return data[0].rstrip(), data[1].lstrip() diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c index dc865934f..e67bca318 100644 --- a/funcs/func_cdr.c +++ b/funcs/func_cdr.c @@ -223,9 +223,11 @@ STASIS_MESSAGE_TYPE_DEFN_LOCAL(cdr_prop_write_message_type); static struct timeval cdr_retrieve_time(struct ast_channel *chan, const char *time_name) { - struct timeval time; + struct timeval time = { 0 }; char *value = NULL; char tempbuf[128]; + long int tv_sec; + long int tv_usec; if (ast_strlen_zero(ast_channel_name(chan))) { /* Format request on a dummy channel */ @@ -234,7 +236,11 @@ static struct timeval cdr_retrieve_time(struct ast_channel *chan, const char *ti ast_cdr_getvar(ast_channel_name(chan), time_name, tempbuf, sizeof(tempbuf)); } - if (sscanf(tempbuf, "%ld.%ld", &time.tv_sec, &time.tv_usec) != 2) { + /* time.tv_usec is suseconds_t, which could be int or long */ + if (sscanf(tempbuf, "%ld.%ld", &tv_sec, &tv_usec) == 2) { + time.tv_sec = tv_sec; + time.tv_usec = tv_usec; + } else { ast_log(AST_LOG_WARNING, "Failed to fully extract '%s' from CDR\n", time_name); } diff --git a/main/rtp_engine.c b/main/rtp_engine.c index 8d46bfdcc..50398a5c6 100644 --- a/main/rtp_engine.c +++ b/main/rtp_engine.c @@ -737,6 +737,7 @@ int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, } else { new_type->format = t->payload_type.format; } + if (new_type->format) { /* SDP parsing automatically increases the reference count */ new_type->format = ast_format_parse_sdp_fmtp(new_type->format, ""); @@ -1773,7 +1774,11 @@ static void add_static_payload(int map, struct ast_format *format, int rtp_code) int x; struct ast_rtp_payload_type *type; - ast_assert(map < ARRAY_LEN(static_RTP_PT)); + /* + * ARRAY_LEN's result is cast to an int so 'map' is not autocast to a size_t, + * which if negative would cause an assertion. + */ + ast_assert(map < (int)ARRAY_LEN(static_RTP_PT)); ast_rwlock_wrlock(&static_RTP_PT_lock); if (map < 0) { @@ -1784,6 +1789,7 @@ static void add_static_payload(int map, struct ast_format *format, int rtp_code) break; } } + if (map < 0) { if (format) { ast_log(LOG_WARNING, "No Dynamic RTP mapping available for format %s\n", @@ -1815,14 +1821,10 @@ static void add_static_payload(int map, struct ast_format *format, int rtp_code) int ast_rtp_engine_load_format(struct ast_format *format) { - char *codec_name = ast_strdupa(ast_format_get_name(format)); - - codec_name = ast_str_to_upper(codec_name); - set_next_mime_type(format, 0, ast_codec_media_type2str(ast_format_get_type(format)), - codec_name, + ast_format_get_codec_name(format), ast_format_get_sample_rate(format)); add_static_payload(-1, format, 0); |