andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From d362196eda904e95cf99e7c784b7dfda36b05e21 Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Mon, 25 Mar 2013 10:35:31 -0400
dc8c34
Subject: [PATCH 41/42] Ticket 628 - crash in aci evaluation
dc8c34
dc8c34
Bug Description:  When trying to get effective rights on a entry that does not exist,
dc8c34
                  can lead to a crash from dereferencing a NULL pointer.
dc8c34
dc8c34
Fix Description:  Check for NULL entry pointers and return the appropriate error.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/628
dc8c34
dc8c34
Reviewed by: nhosoi(Thanks Noriko!)
dc8c34
(cherry picked from commit ac8ceb91e42c31672147018d9d654879970dd38d)
dc8c34
---
dc8c34
 ldap/servers/slapd/entry.c | 28 +++++++++++++++++-----------
dc8c34
 1 file changed, 17 insertions(+), 11 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
dc8c34
index 58a9d51..1926417 100644
dc8c34
--- a/ldap/servers/slapd/entry.c
dc8c34
+++ b/ldap/servers/slapd/entry.c
dc8c34
@@ -2312,7 +2312,11 @@ slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **
dc8c34
 int
dc8c34
 slapi_entry_attr_find( const Slapi_Entry *e, const char *type, Slapi_Attr **a )
dc8c34
 {
dc8c34
-	int r= -1;
dc8c34
+	int r = -1;
dc8c34
+
dc8c34
+	if(e == NULL){
dc8c34
+		return r;
dc8c34
+	}
dc8c34
 	*a = attrlist_find( e->e_attrs, type );
dc8c34
 	if (*a != NULL)
dc8c34
 	{
dc8c34
@@ -2323,11 +2327,11 @@ slapi_entry_attr_find( const Slapi_Entry *e, const char *type, Slapi_Attr **a )
dc8c34
 			 * Our state information storage scheme can cause this, since
dc8c34
 			 * we have to hang onto the deleted value state information.
dc8c34
 			 */
dc8c34
-			 *a= NULL;
dc8c34
+			 *a = NULL;
dc8c34
 		}
dc8c34
 		else
dc8c34
 		{
dc8c34
-			r= 0;
dc8c34
+			r = 0;
dc8c34
 		}
dc8c34
 	}
dc8c34
 	return r;
dc8c34
@@ -2951,18 +2955,20 @@ slapi_entry_attr_has_syntax_value(const Slapi_Entry *e,
dc8c34
 								const char *type,
dc8c34
 								const Slapi_Value *value)
dc8c34
 {
dc8c34
-    int r= 0;
dc8c34
-	Slapi_Attr *attr;
dc8c34
+    int r = 0;
dc8c34
+    Slapi_Attr *attr;
dc8c34
 
dc8c34
+    if(e == NULL){
dc8c34
+        return r;
dc8c34
+    }
dc8c34
     if(slapi_entry_attr_find(e, type, &attr)==0)
dc8c34
     {
dc8c34
-		const struct berval *bv = slapi_value_get_berval(value);
dc8c34
+        const struct berval *bv = slapi_value_get_berval(value);
dc8c34
 
dc8c34
-		if ( bv != NULL) {	
dc8c34
-        	r = (slapi_attr_value_find(attr, bv) == 0);
dc8c34
-		}
dc8c34
-    
dc8c34
-	}
dc8c34
+        if ( bv != NULL) {
dc8c34
+            r = (slapi_attr_value_find(attr, bv) == 0);
dc8c34
+        }
dc8c34
+    }
dc8c34
 	
dc8c34
     return r;			
dc8c34
 }
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34