ARI: Fix crash when POST /playback/{id}/control does not have an operation parameter.
authorRichard Mudgett <rmudgett@digium.com>
Wed, 16 Oct 2013 21:22:25 +0000 (21:22 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 16 Oct 2013 21:22:25 +0000 (21:22 +0000)
(closes issue ASTERISK-22680)
Reported by: John Bigelow
........

Merged revisions 401107 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@401108 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/ari/resource_playback.c

index 64afe10..7cb1d28 100644 (file)
@@ -68,7 +68,6 @@ void ast_ari_stop_playback(struct ast_variable *headers,
        }
 
        res = stasis_app_playback_operation(playback, STASIS_PLAYBACK_STOP);
-
        switch (res) {
        case STASIS_PLAYBACK_OPER_OK:
                ast_ari_response_no_content(response);
@@ -93,6 +92,11 @@ void ast_ari_control_playback(struct ast_variable *headers,
        enum stasis_app_playback_media_operation oper;
        enum stasis_playback_oper_results res;
 
+       if (!args->operation) {
+               ast_ari_response_error(response, 400,
+                       "Bad Request", "Missing operation");
+               return;
+       }
        if (strcmp(args->operation, "unpause") == 0) {
                oper = STASIS_PLAYBACK_UNPAUSE;
        } else if (strcmp(args->operation, "pause") == 0) {
@@ -108,7 +112,6 @@ void ast_ari_control_playback(struct ast_variable *headers,
                        "Bad Request", "Invalid operation %s",
                        args->operation);
                return;
-
        }
 
        playback = stasis_app_playback_find_by_id(args->playback_id);
@@ -119,7 +122,6 @@ void ast_ari_control_playback(struct ast_variable *headers,
        }
 
        res = stasis_app_playback_operation(playback, oper);
-
        switch (res) {
        case STASIS_PLAYBACK_OPER_OK:
                ast_ari_response_no_content(response);