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

--HG--
branch : 1.7

visudo.c

index c000046c9f10eebcba6f86a0c1a28a82450d6713..62ed9880eed8da822c8e2f01f7367a09391487a6 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -1040,18 +1040,16 @@ alias_remove_recursive(name, type)
     struct alias *a;
     int rval = TRUE;
 
-    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);
     return rval;
 }