zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone
Blob Blame History Raw
From ed430bcca3e1cf0788fc15786002b0b1c31a130b Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Fri, 30 Nov 2018 11:45:39 -0500
Subject: [PATCH] Ticket 50063 - Crash after attempting to restore a single
 backend

Description:  While we do not support backup/restore of individual backends,
              it should not crash the server either.  PR_OpenDir will crash
              if the file name is NULL, so this fix just prevents the crash
              by returning an error if the filename is NULL.

https://pagure.io/389-ds-base/issue/50063

Reviewed by: firstyear & tbordaz(Thanks!!)

(cherry picked from commit d36f796a7b35bade5a05e197690abf4e49d212ce)
---
 ldap/servers/slapd/back-ldbm/dblayer.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index fa931ccbf..64a4e9e4f 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -5292,6 +5292,11 @@ dblayer_delete_database_ex(struct ldbminfo *li, char *instance, char *cldir)
     }
 
     /* now smash everything else in the db/ dir */
+    if (priv->dblayer_home_directory == NULL){
+        slapi_log_err(SLAPI_LOG_ERR, "dblayer_delete_database_ex",
+                      "dblayer_home_directory is NULL, can not proceed\n");
+        return -1;
+    }
     dirhandle = PR_OpenDir(priv->dblayer_home_directory);
     if (!dirhandle) {
         slapi_log_err(SLAPI_LOG_ERR, "dblayer_delete_database_ex", "PR_OpenDir (%s) failed (%d): %s\n",
-- 
2.17.2