]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix several crashes in MeetMeAdmin
authorKinsey Moore <kmoore@digium.com>
Fri, 13 Sep 2013 13:31:24 +0000 (13:31 +0000)
committerKinsey Moore <kmoore@digium.com>
Fri, 13 Sep 2013 13:31:24 +0000 (13:31 +0000)
This change ensures that MeetMeAdmin commands requiring a user actually
get a user and fixes another issue where an extra dereference could
occur for a last-entered user being ejected if a user identifier was
also provided.

(closes issue ASTERISK-21907)
Reported by: Alex Epshteyn
Review: https://reviewboard.asterisk.org/r/2844/

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

apps/app_meetme.c

index f100503024ee1c0a2c2ac302109edc9440e8d348..d0fdc4bbf5c846f9ce8cb74a018cec0e48f0d6f1 100644 (file)
@@ -4838,6 +4838,23 @@ static int admin_exec(struct ast_channel *chan, const char *data) {
                        res = -2;
                        goto usernotfound;
                }
+       } else {
+               /* fail for commands that require a user */
+               switch (*args.command) {
+               case 'm': /* Unmute */
+               case 'M': /* Mute */
+               case 't': /* Lower user's talk volume */
+               case 'T': /* Raise user's talk volume */
+               case 'u': /* Lower user's listen volume */
+               case 'U': /* Raise user's listen volume */
+               case 'r': /* Reset user's volume level */
+               case 'k': /* Kick user */
+                       res = -2;
+                       ast_log(LOG_NOTICE, "No user specified!\n");
+                       goto usernotfound;
+               default:
+                       break;
+               }
        }
 
        switch (*args.command) {
@@ -4853,21 +4870,24 @@ static int admin_exec(struct ast_channel *chan, const char *data) {
        case 101: /* e: Eject last user*/
        {
                int max_no = 0;
+               struct ast_conf_user *eject_user;
 
-               /* If they passed in a user, disregard it */
-               if (user) {
-                       ao2_ref(user, -1);
+               ao2_callback(cnf->usercontainer, OBJ_NODATA, user_max_cmp, &max_no);
+               eject_user = ao2_find(cnf->usercontainer, &max_no, 0);
+               if (!eject_user) {
+                       res = -1;
+                       ast_log(LOG_NOTICE, "No last user to kick!\n");
+                       break;
                }
 
-               ao2_callback(cnf->usercontainer, OBJ_NODATA, user_max_cmp, &max_no);
-               user = ao2_find(cnf->usercontainer, &max_no, 0);
-               if (!ast_test_flag64(&user->userflags, CONFFLAG_ADMIN))
-                       user->adminflags |= ADMINFLAG_KICKME;
-               else {
+               if (!ast_test_flag64(&eject_user->userflags, CONFFLAG_ADMIN)) {
+                       eject_user->adminflags |= ADMINFLAG_KICKME;
+               } else {
                        res = -1;
                        ast_log(LOG_NOTICE, "Not kicking last user, is an Admin!\n");
                }
-               ao2_ref(user, -1);
+
+               ao2_ref(eject_user, -1);
                break;
        }
        case 77: /* M: Mute */