Browse Source

Bug 614511 - fix coverity Defect Type: Null pointer dereferences issues 11846 - 11891

https://bugzilla.redhat.com/show_bug.cgi?id=614511

11856
Comment: If the aci "rule" does not include "($dn)", there is no
pointer assigined to aci_macro and matched_val is NULL.  In that
case, acllas_replace_dn_macro is supposed to return just "user"
itself regardless of [$dn].
Noriko Hosoi 15 years ago
parent
commit
5d578b850a
1 changed files with 7 additions and 8 deletions
  1. 7 8
      ldap/servers/plugins/acl/acllas.c

+ 7 - 8
ldap/servers/plugins/acl/acllas.c

@@ -4148,19 +4148,21 @@ acllas_replace_dn_macro( char *rule, char *matched_val, lasInfo *lasinfo) {
 	
 	/* Determine what the rule's got once */
 	if ( strstr(rule, ACL_RULE_MACRO_DN_KEY) != NULL) {
+		/* ($dn) exists */
 		has_macro_dn = 1;
 	}
 
 	if ( strstr(rule, ACL_RULE_MACRO_DN_LEVELS_KEY) != NULL) {
+		/* [$dn] exists */
 		has_macro_levels = 1;
 	}
 
-	if ( !has_macro_dn && !has_macro_levels ) {		 
+	if ( !has_macro_dn ) { /* No $(dn) */
 
 		/*
 		 * No $dn thing, just return a list with two elements, rule and NULL.
 		 * charray_add will create the list and null terminate it.		
-		*/
+		 */
 
 		charray_add( &a, slapi_ch_strdup(rule));
 		return(a);
@@ -4170,12 +4172,9 @@ acllas_replace_dn_macro( char *rule, char *matched_val, lasInfo *lasinfo) {
 		 * Have an occurrence of the macro rules
 		 *
 		 * First, replace all occurrencers of ($dn) with the matched_val
-		*/
-			
-		if ( has_macro_dn) {
-			patched_rule =
+		 */
+		patched_rule =
 				acl_replace_str(rule, ACL_RULE_MACRO_DN_KEY, matched_val);
-		}
 		
 		/* If there are no [$dn] we're done */
 
@@ -4196,7 +4195,7 @@ acllas_replace_dn_macro( char *rule, char *matched_val, lasInfo *lasinfo) {
 			 * If has_macro_dn then patched_rule is the rule to strart with,
 			 * and this needs to be freed at the end, otherwise
 			 * just use rule.
-			*/
+			 */
 	
 			if (patched_rule) {
 				rule_to_use = patched_rule;