]> granicus.if.org Git - sudo/commitdiff
Sync the "cache hit" debug messages with the "cached" debug messages.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 4 May 2016 14:55:21 +0000 (08:55 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 4 May 2016 14:55:21 +0000 (08:55 -0600)
This fixes a bug where we could dereference a NULL pointer when we
look up a negative cached entry which is stored as a NULL passwd
or group struct pointer.  Bug #743.

plugins/sudoers/pwutil.c

index dee2b42ca5a000df7bbe7deb40ed87c20aad6ee2..a8fddb5dd348c134d565ba20df48a5be8f3d7b8a 100644 (file)
@@ -139,8 +139,8 @@ sudo_getpwuid(uid_t uid)
        item = node->data;
        sudo_debug_printf(SUDO_DEBUG_DEBUG,
            "%s: uid %u [%s] -> user %s [%s] (cache hit)", __func__,
-           (unsigned int)uid, key.registry, item->d.pw->pw_name,
-           item->registry);
+           (unsigned int)uid, key.registry,
+           item->d.pw ? item->d.pw->pw_name : "unknown", item->registry);
        goto done;
     }
     /*
@@ -202,8 +202,8 @@ sudo_getpwnam(const char *name)
     if ((node = rbfind(pwcache_byname, &key)) != NULL) {
        item = node->data;
        sudo_debug_printf(SUDO_DEBUG_DEBUG,
-           "%s: user %s [%s] -> uid %u [%s] (cache hit)", __func__, name,
-           key.registry, (unsigned int)item->d.pw->pw_uid, item->registry);
+           "%s: user %s [%s] -> uid %d [%s] (cache hit)", __func__, name,
+           key.registry, item->d.pw ? (int)item->d.pw->pw_uid : -1, item->registry);
        goto done;
     }
     /*
@@ -461,8 +461,8 @@ sudo_getgrgid(gid_t gid)
        item = node->data;
        sudo_debug_printf(SUDO_DEBUG_DEBUG,
            "%s: gid %u [%s] -> group %s [%s] (cache hit)", __func__,
-           (unsigned int)gid, key.registry, item->d.gr->gr_name,
-           item->registry);
+           (unsigned int)gid, key.registry,
+           item->d.gr ? item->d.gr->gr_name : "unknown", item->registry);
        goto done;
     }
     /*