ARI: Correct segfault with /variable calls are missing ?variable parameter.

Both /asterisk/variable and /channel/{channelId}/variable requires a
?variable parameter to be passed into the query. But we weren't checking
for the parameter being missing, which caused a segfault.

All calls now properly return 400 Bad Request errors when the parameter
is missing. The Swagger api-docs were updated accordingly.

(closes issue ASTERISK-22273)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397306 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee
2013-08-21 16:23:59 +00:00
parent a6da087716
commit 5762c1b4ac
6 changed files with 47 additions and 6 deletions

View File

@@ -143,12 +143,20 @@ void ast_ari_get_asterisk_info(struct ast_variable *headers,
void ast_ari_get_global_var(struct ast_variable *headers, struct ast_get_global_var_args *args, struct ast_ari_response *response)
{
RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
RAII_VAR(struct ast_str *, tmp, ast_str_create(32), ast_free);
RAII_VAR(struct ast_str *, tmp, NULL, ast_free);
const char *value;
ast_assert(response != NULL);
if (ast_strlen_zero(args->variable)) {
ast_ari_response_error(
response, 400, "Bad Request",
"Variable name is required");
return;
}
tmp = ast_str_create(32);
if (!tmp) {
ast_ari_response_alloc_failed(response);
return;