diff options
author | George Joseph <george.joseph@fairview5.com> | 2016-03-06 13:38:41 -0700 |
---|---|---|
committer | George Joseph <george.joseph@fairview5.com> | 2016-03-07 12:15:58 -0700 |
commit | 530cff5f5f3be4d2f53e84a656f10f2f43638d1c (patch) | |
tree | 8c61022785505b44dc0e9a7c9af3adbce66b39cd /include/asterisk/strings.h | |
parent | 6e58f83d8d68045574bcb432c74f38183a559bab (diff) |
res_pjsip: Strip spaces from items parsed from comma-separated lists
Configurations like "aors = a, b, c" were either ignoring everything after "a"
or trying to look up " b". Same for mailboxes, ciphers, contacts and a few
others.
To fix, all the strsep(©, ",") calls have been wrapped in ast_strip. To
facilitate this, ast_strip, ast_skip_blanks and ast_skip_nonblanks were
updated to handle null pointers.
In some cases, an ast_strlen_zero() test was added to skip consecutive commas.
There was also an attempt to ast_free an ast_strdupa'd string in
ast_sip_for_each_aor which was causing a SEGV. I removed it.
Although this issue was reported for realtime, the issue was in the res_pjsip
modules so all config mechanisms were affected.
ASTERISK-25829 #close
Reported-by: Mateusz Kowalski
Change-Id: I0b22a2cf22a7c1c50d4ecacbfa540155bec0e7a2
Diffstat (limited to 'include/asterisk/strings.h')
-rw-r--r-- | include/asterisk/strings.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index af5ae6c55..3701b5305 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -145,8 +145,12 @@ static int force_inline attribute_pure ast_ends_with(const char *str, const char AST_INLINE_API( char * attribute_pure ast_skip_blanks(const char *str), { - while (*str && ((unsigned char) *str) < 33) - str++; + if (str) { + while (*str && ((unsigned char) *str) < 33) { + str++; + } + } + return (char *) str; } ) @@ -184,8 +188,12 @@ char *ast_trim_blanks(char *str), AST_INLINE_API( char * attribute_pure ast_skip_nonblanks(const char *str), { - while (*str && ((unsigned char) *str) > 32) - str++; + if (str) { + while (*str && ((unsigned char) *str) > 32) { + str++; + } + } + return (char *) str; } ) |