[Asterisk-code-review] resource_channels.c: Fix wrong external media parameter parse (asterisk[master])

Sungtae Kim asteriskteam at digium.com
Thu Sep 2 13:24:23 CDT 2021


Attention is currently required from: Kevin Harwell.
Sungtae Kim has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/16404 )

Change subject: resource_channels.c: Fix wrong external media parameter parse
......................................................................


Patch Set 2:

(2 comments)

Commit Message:

https://gerrit.asterisk.org/c/asterisk/+/16404/comment/61217677_f34801e0 
PS2, Line 11: ASTERISK-29622
> I ran Asterisk (18 at least) using the exact curl command on the issue, and it seemingly worked fine […]
Hm... that's strange. I checked this asterisk-18.3.0 and current master branch.

```
$ curl -s -X POST -u asterisk:asterisk 127.0.0.1:8088/ari/channels/externalMedia \
>  -H 'Content-Type: application/json; charset=utf-8' \
>  -d '{"app": "sdp", "external_host": "test.com:5060", "transport": "udp", "format": "ulaw", "connection_type": "client", "direction": "both", "encapsulation": "rtp"}'
{"message":"app cannot be empty"}

$ asterisk -rx "core show version"
Asterisk 18.3.0 built by root @ 9d6bf8690382 on a x86_64 running Linux on 2021-04-16 05:16:08 UTC
```

Have you run the curl command with -d option? Because if you parse the options to the url parameter, that is working.

```
$ curl -s -X POST -u asterisk:asterisk 127.0.0.1:8088/ari/channels/externalMedia\?app=voipbin\&external_host=127.0.0.1:5090\&transport=udp\&format=ulaw

{"id":"asterisk-call-5765d977d8-c4k5q-1630606830.44","name":"UnicastRTP/127.0.0.1:5090-0x7f79a0089780","state":"Down","caller":{"name":"","number":""},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"default","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2021-09-02T18:20:30.533+0000","language":"en","channelvars":{"UNICASTRTP_LOCAL_PORT":"10656","UNICASTRTP_LOCAL_ADDRESS":"127.0.0.1"}}
```


File res/ari/resource_channels.c:

https://gerrit.asterisk.org/c/asterisk/+/16404/comment/8adf7b86_2b040393 
PS2, Line 2192: 	if (args->variables) {
              : 		struct ast_json *json_variables;
              : 
              : 		ast_ari_channels_external_media_parse_body(args->variables, args);
              : 		json_variables = ast_json_object_get(args->variables, "variables");
              : 		if (json_variables
              : 			&& json_to_ast_variables(response, json_variables, &variables)) {
              : 			return;
              : 		}
              : 	}
> I'm missing something I think. […]
Because make the ast_ari_channels_external_media_parse_body() function before than parameter validation.



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16404
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I49509c48a6cbc0fb4165bfa4f834b5e8b9ace20d
Gerrit-Change-Number: 16404
Gerrit-PatchSet: 2
Gerrit-Owner: Sungtae Kim <pchero21 at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Attention: Kevin Harwell <kharwell at digium.com>
Gerrit-Comment-Date: Thu, 02 Sep 2021 18:24:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210902/78a82c91/attachment-0001.html>


More information about the asterisk-code-review mailing list