]> granicus.if.org Git - sudo/commitdiff
Fix some potential problems found by the clang static analyzer, none
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 13 Aug 2011 16:29:52 +0000 (12:29 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 13 Aug 2011 16:29:52 +0000 (12:29 -0400)
serious.

--HG--
branch : 1.7

check.c
ldap.c
parse.c
toke.c
toke.l

diff --git a/check.c b/check.c
index df44bfca73934706d724cdc61a8b94d8e3f44280..035d4b6bcf20785ed4d55e9983b1ecc6323cc2b7 100644 (file)
--- a/check.c
+++ b/check.c
@@ -659,7 +659,8 @@ remove_timestamp(remove)
                    path, strerror(errno));
                remove = FALSE;
            }
-       } else {
+       }
+       if (!remove) {
            timevalclear(&tv);
            if (touch(-1, path, &tv) == -1 && errno != ENOENT)
                error(1, "can't reset %s to Epoch", path);
diff --git a/ldap.c b/ldap.c
index 3097af7dabe1b298fc2ee9ce3a17d69cf4f5865f..d26e45812e6d28837c266d6652ccf9aeb8db4843 100644 (file)
--- a/ldap.c
+++ b/ldap.c
@@ -2141,7 +2141,7 @@ sudo_ldap_setdefs(nss)
        }
        result = NULL;
        rc = ldap_search_ext_s(ld, base->val, LDAP_SCOPE_SUBTREE,
-           filt, NULL, 0, NULL, NULL, NULL, 0, &result);
+           filt, NULL, 0, NULL, NULL, tvp, 0, &result);
        if (rc == LDAP_SUCCESS && (entry = ldap_first_entry(ld, result))) {
            DPRINTF(("found:%s", ldap_get_dn(ld, entry)), 1);
            sudo_ldap_parse_options(ld, entry);
@@ -2168,7 +2168,7 @@ sudo_ldap_lookup(nss, ret, pwflag)
     struct sudo_ldap_handle *handle = nss->handle;
     LDAP *ld;
     LDAPMessage *entry;
-    int i, rc, setenv_implied, matched = UNSPEC;
+    int i, rc, setenv_implied;
     struct ldap_result *lres = NULL;
 
     if (handle == NULL || handle->ld == NULL)
@@ -2183,11 +2183,12 @@ sudo_ldap_lookup(nss, ret, pwflag)
      * password is required, so the order of the entries doesn't matter.
      */
     if (pwflag) {
-       DPRINTF(("perform search for pwflag %d", pwflag), 1);
        int doauth = UNSPEC;
+       int matched = UNSPEC;
        enum def_tupple pwcheck = 
            (pwflag == -1) ? never : sudo_defs_table[pwflag].sd_un.tuple;
 
+       DPRINTF(("perform search for pwflag %d", pwflag), 1);
        for (i = 0; i < lres->nentries; i++) {
            entry = lres->entries[i].entry;
            if ((pwcheck == any && doauth != FALSE) ||
@@ -2237,7 +2238,6 @@ sudo_ldap_lookup(nss, ret, pwflag)
        if (rc != UNSPEC) {
            /* We have a match. */
            DPRINTF(("Command %sallowed", rc == TRUE ? "" : "NOT "), 1);
-           matched = TRUE;
            if (rc == TRUE) {
                DPRINTF(("LDAP entry: %p", entry), 1);
                /* Apply entry-specific options. */
@@ -2447,7 +2447,7 @@ sudo_ldap_result_get(nss, pw)
            }
            result = NULL;
            rc = ldap_search_ext_s(ld, base->val, LDAP_SCOPE_SUBTREE, filt,
-               NULL, 0, NULL, NULL, NULL, 0, &result);
+               NULL, 0, NULL, NULL, tvp, 0, &result);
            if (rc != LDAP_SUCCESS) {
                DPRINTF(("nothing found for '%s'", filt), 1);
                continue;
diff --git a/parse.c b/parse.c
index acf8e5fdc8145b4a213558d446e47d917529a0bc..1da7d0a028d5407a13f29cef2762938b214a3907 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -526,34 +526,29 @@ display_bound_defaults(dtype, lbuf)
 {
     struct defaults *d;
     struct member *m, *binding = NULL;
-    char *dname, *dsep;
+    char *dsep;
     int atype, nfound = 0;
 
     switch (dtype) {
        case DEFAULTS_HOST:
            atype = HOSTALIAS;
-           dname = "host";
            dsep = "@";
            break;
        case DEFAULTS_USER:
            atype = USERALIAS;
-           dname = "user";
            dsep = ":";
            break;
        case DEFAULTS_RUNAS:
            atype = RUNASALIAS;
-           dname = "runas";
            dsep = ">";
            break;
        case DEFAULTS_CMND:
            atype = CMNDALIAS;
-           dname = "cmnd";
            dsep = "!";
            break;
        default:
            return -1;
     }
-    /* printf("Per-%s Defaults entries:\n", dname); */
     tq_foreach_fwd(&defaults, d) {
        if (d->type != dtype)
            continue;
diff --git a/toke.c b/toke.c
index 849695a4628bdc69cabd7d6212a5a07651bec197..344eb7c05915ea38a720a1bdecd358d0b7e2727a 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -4,7 +4,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /home/cvs/openbsd/src/usr.bin/lex/flex.skl,v 1.11 2010/08/04 18:24:50 millert Exp $
+ * $Header: /cvs/src/usr.bin/lex/flex.skl,v 1.11 2010/08/04 18:24:50 millert Exp $
  */
 
 #define FLEX_SCANNER
@@ -3615,8 +3615,10 @@ parse_include(base)
 
     /* Make a copy of path and return it. */
     len += (int)(ep - cp);
-    if ((path = malloc(len + 1)) == NULL)
+    if ((path = malloc(len + 1)) == NULL) {
        yyerror("unable to allocate memory");
+       return NULL;
+    }
     if (subst) {
        /* substitute for %h */
        char *pp = path;
diff --git a/toke.l b/toke.l
index 7181d3117a09f40608812bab95fe0574bd609348..b1569b4e9d659ac350ddc727461b662f1ce53bca 100644 (file)
--- a/toke.l
+++ b/toke.l
@@ -906,8 +906,10 @@ parse_include(base)
 
     /* Make a copy of path and return it. */
     len += (int)(ep - cp);
-    if ((path = malloc(len + 1)) == NULL)
+    if ((path = malloc(len + 1)) == NULL) {
        yyerror("unable to allocate memory");
+       return NULL;
+    }
     if (subst) {
        /* substitute for %h */
        char *pp = path;