From c606cfcecb3d3403dfd3d1a90bd1d2b061eb3b6e Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 2 Jul 2010 00:31:44 -0500 Subject: Bug 610119 - fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199 https://bugzilla.redhat.com/show_bug.cgi?id=610119 Resolves: bug 610119 Bug description: Fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199 Fix description: Catch possible NULL pointer in acl_usr_cache_insert(). --- lib/libaccess/usrcache.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/libaccess/usrcache.cpp b/lib/libaccess/usrcache.cpp index b0ba35fd..181edfdc 100644 --- a/lib/libaccess/usrcache.cpp +++ b/lib/libaccess/usrcache.cpp @@ -363,6 +363,11 @@ int acl_usr_cache_insert (const char *uid, const char *dbname, PRCList *tail = PR_LIST_TAIL(usrobj_list); usrobj = USEROBJ_PTR(tail); + if (!usrobj) { + rv = LAS_EVAL_FAIL; + goto out; + } + /* If the removed usrobj is in the hashtable, remove it from there */ if (usrobj->hashtable) { PR_HashTableRemove(usrobj->hashtable, usrobj); @@ -393,18 +398,11 @@ int acl_usr_cache_insert (const char *uid, const char *dbname, PR_REMOVE_LINK(&usrobj->list); PR_INSERT_AFTER(&usrobj->list, usrobj_list); - /* Set the time in the UserCacheObj */ - if (usrobj) { - rv = LAS_EVAL_TRUE; - } - else { - rv = LAS_EVAL_FAIL; - } - DBG_PRINT4("acl_usr_cache_insert: derCert = \"%s\" uid = \"%s\" at time = %ld\n", usrobj->derCert ? (char *)usrobj->derCert->data : "", uid, time); +out: user_hash_crit_exit(); return rv; } -- cgit