]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_ari: Remove requirement that body exists when debug is on.
authorJoshua Colp <jcolp@digium.com>
Thu, 3 May 2018 11:34:32 +0000 (11:34 +0000)
committerJoshua Colp <jcolp@digium.com>
Thu, 3 May 2018 11:36:50 +0000 (05:36 -0600)
The "ari set debug" code for incoming requests incorrectly assumed
that all requests would contain a body. If one did not exist the
request would be incorrectly rejected. The response that was sent
was also incomplete as an incorrect function was used to construct
the response.

The code has now been changed to no longer require a request to have
a body and the response updated to use the correct function.

ASTERISK-27801

Change-Id: I4eef036ad54550a4368118cc348765ecac25e0f8

res/res_ari.c

index 9104eded3a6c9fc7daac1a58adb85473ba139c67..8a01809494a3afa0fd094260628d16dd8340a4a6 100644 (file)
@@ -985,9 +985,9 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
                struct ast_str *buf = ast_str_create(512);
                char *str = ast_json_dump_string_format(body, ast_ari_json_format());
 
-               if (!buf || !str) {
+               if (!buf || (body && !str)) {
                        ast_http_request_close_on_completion(ser);
-                       ast_http_error(ser, 500, "Server Error", "Out of memory");
+                       ast_ari_response_error(&response, 500, "Server Error", "Out of memory");
                        ast_json_free(str);
                        ast_free(buf);
                        goto request_failed;
@@ -1001,7 +1001,7 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
                for (var = get_params; var; var = var->next) {
                        ast_str_append(&buf, 0, "%s: %s\n", var->name, var->value);
                }
-               ast_verbose("%sbody:\n%s\n\n", ast_str_buffer(buf), str);
+               ast_verbose("%sbody:\n%s\n\n", ast_str_buffer(buf), S_OR(str, ""));
                ast_json_free(str);
                ast_free(buf);
        }