res_geolocation: Fix segfault when there's an empty element

Fixed a segfault caused by var_list_from_loc_info() encountering
an empty location info element.

Fixed an issue in ast_strsep() where a value with only whitespace
wasn't being preserved.

Fixed an issue in ast_variable_list_from_quoted_string() where
an empty value was considered a failure.

ASTERISK-30215
Reported by: Dan Cropp

Change-Id: Ieca64e061a6d9298f0196c694b60d986ef82613a
This commit is contained in:
George Joseph
2022-09-13 07:14:37 -06:00
parent 2f5cfa548f
commit 4ab3cd6f86
5 changed files with 23 additions and 13 deletions

View File

@@ -1961,13 +1961,13 @@ AST_TEST_DEFINE(variable_list_from_string)
break;
}
parse_string = "abc = 'def', ghi = 'j,kl', mno='pq=r', stu = 'vwx=\"yz\", ABC = \"DEF\"'";
parse_string = "000= '', 111=, 222 = , 333 = ' ', abc = 'def', ghi = 'j,kl', mno='pq=r', stu = 'vwx=\"yz\", ABC = \"DEF\"'";
list = ast_variable_list_from_quoted_string(parse_string, ",", "=", "'");
ast_test_validate(test, list != NULL);
str = ast_variable_list_join(list, "|", "^", "@", NULL);
ast_test_validate(test,
strcmp(ast_str_buffer(str), "abc^@def@|ghi^@j,kl@|mno^@pq=r@|stu^@vwx=\"yz\", ABC = \"DEF\"@") == 0);
strcmp(ast_str_buffer(str), "000^@@|111^@@|222^@@|333^@ @|abc^@def@|ghi^@j,kl@|mno^@pq=r@|stu^@vwx=\"yz\", ABC = \"DEF\"@") == 0);
return AST_TEST_PASS;
}