]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res/res_ari: Fix null endpoint handle
authorSungtae Kim <pchero21@gmail.com>
Sat, 17 Nov 2018 02:33:20 +0000 (03:33 +0100)
committersungtae kim <pchero21@gmail.com>
Mon, 19 Nov 2018 11:22:10 +0000 (06:22 -0500)
The res_ari(POST /channels/create handler) deos not check the endpoint
parameter length. And it causes core
dump.
Fixed it to check the parameter length. Also fixed memory leak.

ASTERISK-28169

Change-Id: Ibf10a9eb8a2e3a9ee1e13fbe748b2ecf955c3993

res/ari/resource_channels.c

index cdf0f88207f5b93866da62427e71cff446ba36f0..bca32f1243439c73bc8392929b0cfd1b8c281727 100644 (file)
@@ -1748,15 +1748,21 @@ void ast_ari_channels_create(struct ast_variable *headers,
        struct ast_format_cap *request_cap;
        struct ast_channel *originator;
 
-       chan_data = ast_calloc(1, sizeof(*chan_data));
-       if (!chan_data) {
-               ast_ari_response_alloc_failed(response);
+       if (!ast_strlen_zero(args->originator) && !ast_strlen_zero(args->formats)) {
+               ast_ari_response_error(response, 400, "Bad Request",
+                       "Originator and formats can't both be specified");
                return;
        }
 
-       if (!ast_strlen_zero(args->originator) && !ast_strlen_zero(args->formats)) {
+       if (ast_strlen_zero(args->endpoint)) {
                ast_ari_response_error(response, 400, "Bad Request",
-                       "Originator and formats can't both be specified");
+                       "Endpoint must be specified");
+               return;
+       }
+
+       chan_data = ast_calloc(1, sizeof(*chan_data));
+       if (!chan_data) {
+               ast_ari_response_alloc_failed(response);
                return;
        }