]> granicus.if.org Git - sudo/commitdiff
Fix potential stack overflow due to infinite recursion in alias
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 Jan 2013 12:52:09 +0000 (07:52 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 Jan 2013 12:52:09 +0000 (07:52 -0500)
cycle detection.  From Daniel Kopecek.

plugins/sudoers/visudo.c

index 34abec88f16619fa7a579f9a3b83b5651bc03b3e..2225aff0c4e80509562ac0da223e0a7fb4d28af0 100644 (file)
@@ -1066,18 +1066,16 @@ alias_remove_recursive(char *name, int type)
     bool rval = true;
     debug_decl(alias_remove_recursive, SUDO_DEBUG_ALIAS)
 
-    if ((a = alias_find(name, type)) != NULL) {
+    if ((a = alias_remove(name, type)) != NULL) {
        tq_foreach_fwd(&a->members, m) {
            if (m->type == ALIAS) {
                if (!alias_remove_recursive(m->name, type))
                    rval = false;
            }
        }
+       rbinsert(alias_freelist, a);
     }
     alias_seqno++;
-    a = alias_remove(name, type);
-    if (a)
-       rbinsert(alias_freelist, a);
     debug_return_bool(rval);
 }