Browse Source

Bug 680555 - ns-slapd segfaults if I have more than 100 DBs

https://bugzilla.redhat.com/show_bug.cgi?id=680555
Resolves: bug 680555
Bug Description: ns-slapd segfaults if I have more than 100 DBs
Reviewed by: nhosoi, nkinder (Thanks!)
Branch: master
Fix Description: 1) slapi_mapping_tree_select_all() does
be_list[BE_LIST_SIZE] = NULL
so be_list must be of size BE_LIST_SIZE+1
2) loop counter should check be_index, not index, to see if the loop is
completed
3) if the search is going to hit more backends than we can process, just
return ADMINLIMIT_EXCEEDED with an explanatory error message
4) increase the BE_LIST_SIZE to 1000
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
Rich Megginson 14 years ago
parent
commit
6c4eac9ca6
3 changed files with 12 additions and 4 deletions
  1. 9 1
      ldap/servers/slapd/mapping_tree.c
  2. 2 2
      ldap/servers/slapd/opshared.c
  3. 1 1
      ldap/servers/slapd/slap.h

+ 9 - 1
ldap/servers/slapd/mapping_tree.c

@@ -2178,7 +2178,7 @@ int slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list,
 
     ret = slapi_mtn_get_first_be(node_list, &node, pb, &be, &index, &referral, errorbuf, scope);
 
-    while ((node) &&(index < BE_LIST_SIZE))
+    while ((node) && (be_index <= BE_LIST_SIZE))
     {
         if (ret != LDAP_SUCCESS)
         {
@@ -2204,7 +2204,15 @@ int slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list,
         {
             if (be && !be_isdeleted(be))
             {
+                if (be_index == BE_LIST_SIZE) { /* error - too many backends */
+                    ret_code = LDAP_ADMINLIMIT_EXCEEDED;
+                    PR_snprintf(errorbuf, BUFSIZ-1,
+                                "Error: too many backends match search request - cannot proceed");
+                    slapi_log_error(SLAPI_LOG_FATAL, NULL, "%s\n", errorbuf);
+                    break;
+                } else {
                     be_list[be_index++]=be;
+                }
             }
 
             if (referral)

+ 2 - 2
ldap/servers/slapd/opshared.c

@@ -192,8 +192,8 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
   int             scope;
   Slapi_Backend   *be = NULL;
   Slapi_Backend   *be_single = NULL;
-  Slapi_Backend   *be_list[BE_LIST_SIZE];
-  Slapi_Entry     *referral_list[BE_LIST_SIZE];
+  Slapi_Backend   *be_list[BE_LIST_SIZE+1];
+  Slapi_Entry     *referral_list[BE_LIST_SIZE+1];
   char            ebuf[ BUFSIZ ];
   char            attrlistbuf[ 1024 ], *attrliststr, **attrs = NULL;
   int             rc = 0;

+ 1 - 1
ldap/servers/slapd/slap.h

@@ -299,7 +299,7 @@ typedef void	(*VFP0)(void);
 #define EGG_OBJECT_CLASS		"directory-team-extensible-object"
 #define EGG_FILTER				"(objectclass=directory-team-extensible-object)"
 
-#define BE_LIST_SIZE 100 /* used by mapping tree code to hold be_list stuff */
+#define BE_LIST_SIZE 1000 /* used by mapping tree code to hold be_list stuff */
 
 #define	REPL_DBTYPE		"ldbm"
 #define	REPL_DBTAG		"repl"