From: Todd C. Miller Date: Wed, 25 May 2011 16:54:15 +0000 (-0400) Subject: Set errno to ELOOP in alias_find() if there is a cycle. X-Git-Tag: SUDO_1_8_2~115^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b984928711ad73a08b56dffd67e7f831cfce346;p=sudo Set errno to ELOOP in alias_find() if there is a cycle. Set errno to ENOENT in alias_find() and alias_remove() if the entry could not be found. --- diff --git a/plugins/sudoers/alias.c b/plugins/sudoers/alias.c index 429f6f81f..0b2ad0e06 100644 --- a/plugins/sudoers/alias.c +++ b/plugins/sudoers/alias.c @@ -44,6 +44,7 @@ #include "parse.h" #include "redblack.h" #include +#include /* * Globals @@ -85,15 +86,19 @@ alias_find(char *name, int type) key.name = name; key.type = type; if ((node = rbfind(aliases, &key)) != NULL) { - /* - * Compare the global sequence number with the one stored - * in the alias. If they match then we've seen this alias - * before and found a loop. - */ - a = node->data; - if (a->seqno == alias_seqno) - return NULL; - a->seqno = alias_seqno; + /* + * Compare the global sequence number with the one stored + * in the alias. If they match then we've seen this alias + * before and found a loop. + */ + a = node->data; + if (a->seqno == alias_seqno) { + errno = ELOOP; + return NULL; + } + a->seqno = alias_seqno; + } else { + errno = ENOENT; } return a; } @@ -175,8 +180,10 @@ alias_remove(char *name, int type) key.name = name; key.type = type; - if ((node = rbfind(aliases, &key)) == NULL) + if ((node = rbfind(aliases, &key)) == NULL) { + errno = ENOENT; return NULL; + } return rbdelete(aliases, node); }