From b21b7e65d8c7b6039c2e4c06152dade2ca8d5b9f Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 10 Oct 2019 14:46:35 -0500 Subject: [PATCH] Fix a bug where the database file count is erroneous, since it gets reset to zero for each subfolder encountered. In the worst case it may prevent database recovery from running by returning a false negative, if it happens that the last subfolder encountered had .db files, even though previous subfolders did. --- ldap/servers/slapd/back-ldbm/dblayer.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c index b8e9503..df6d3e3 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.c +++ b/ldap/servers/slapd/back-ldbm/dblayer.c @@ -5559,7 +5559,15 @@ int dblayer_database_size(struct ldbminfo *li, unsigned int *size) return return_value; } - +/* + * Obtain a count of all the BDB files in the indicated directory. + * + * directory : The path to examine. + * count : Output parameter for the final count. + * recurse : 0/1, recursion is not complete, it only goes down one level. + * + * IMPORTANT: 'count' must be set to 0 by the caller before being passed. + */ static int count_dbfiles_in_dir(char *directory, int *count, int recurse) { /* The new recurse argument was added to help with multiple backend @@ -5568,12 +5576,6 @@ static int count_dbfiles_in_dir(char *directory, int *count, int recurse) int return_value = 0; PRDir *dirhandle = NULL; - if (!recurse) { - /* It is really the callers responsibility to set count to 0 before - * calling. However, if recurse isn't true, we can make sure it is - * set to 0. */ - *count = 0; - } dirhandle = PR_OpenDir(directory); if (NULL != dirhandle) { PRDirEntry *direntry = NULL; -- 2.10.5