Browse Source

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 LASDnsBuild().
Endi S. Dewata 15 years ago
parent
commit
9020d0a1ba

+ 1 - 0
include/libaccess/aclerror.h

@@ -237,6 +237,7 @@ NSPR_END_EXTERN_C
 #define	ACLERR4740	4740		/* Cannot add token to hash */
 #define	ACLERR4750	4750		/* Cannot add token to hash */
 #define	ACLERR4760	4760		/* Cannot add token to hash */
+#define	ACLERR4770	4770		/* Invalid attribute pattern */
 
 /* LASDnsEval */
 #define	ACLERR4800	4800		/* Wrong attribute name */

+ 1 - 0
include/libaccess/dbtlibaccess.h

@@ -195,4 +195,5 @@ BEGIN_STR(libaccess)
 	ResDef( DBT_AclUserExistsOutOfMemory, 144, "acl_user_exists: out of memory")
 	ResDef( DBT_AclUserExistsNot, 145, "acl_user_exists: user doesn't exist anymore")
 	ResDef( DBT_AclUserPlistError, 146, "acl_user_exists: plist error")
+	ResDef( DBT_lasdnsbuildInvalidAttributePattern_, 147, "LASDnsBuild invalid attribute pattern\n" )
 END_STR(libaccess)

+ 6 - 0
lib/libaccess/lasdns.cpp

@@ -152,6 +152,12 @@ LASDnsBuild(NSErr_t *errp, char *attr_pattern, LASDnsContext_t *context, int ali
     PRHostEnt *he, host;
 #endif
 
+    if (attr_pattern == NULL) {
+	nserrGenerate(errp, ACLERRINVAL, ACLERR4770, ACL_Program, 1, 
+		      XP_GetAdminStr(DBT_lasdnsbuildInvalidAttributePattern_));
+        return LAS_EVAL_INVALID;
+    }
+
     context->Table = PR_NewHashTable(0,
 				     PR_HashCaseString,
 				     PR_CompareCaseStrings,

+ 1 - 0
lib/libsi18n/getstrmem.h

@@ -259,6 +259,7 @@ static char* libaccess[] = {
   "acl_user_exists: out of memory",
   "acl_user_exists: user doesn't exist anymore",
   "acl_user_exists: plist error",
+  "LASDnsBuild invalid attribute pattern\n",
   emptyString };
 
 /* libraries in bucket for hashKey==9 */