[389-commits] ldap/servers

Noriko Hosoi nhosoi at fedoraproject.org
Mon Jan 27 23:40:57 UTC 2014


 ldap/servers/slapd/back-ldbm/ldbm_usn.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit a6f66e7fcbd5d17d975cc2ac65806d7c64571254
Author: Noriko Hosoi <nhosoi at redhat.com>
Date:   Mon Jan 27 15:15:01 2014 -0800

    Ticket #47659 - ldbm_usn_init: Valgrind reports Invalid read / SIGSEGV
    
    Bug description: A suffix mapping tree could exist without the corresponding
    backend.  The existing code did not properly check the backend returned from
    slapi_mapping_tree_find_backend_for_sdn.  When NULL backend is returned, it
    triggers the NULL pointer dereference.
    
    Fix description: This patch added a NULL backend check to usn_get_last_usn,
    and moved a logging to the if clause where the backend is not NULL.
    
    https://fedorahosted.org/389/ticket/47659
    
    Reviewed by rmeggins at redhat.com (Thank you, Rich!!)

diff --git a/ldap/servers/slapd/back-ldbm/ldbm_usn.c b/ldap/servers/slapd/back-ldbm/ldbm_usn.c
index 7c11a68..1ca16b1 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_usn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_usn.c
@@ -80,10 +80,11 @@ ldbm_usn_init(struct ldbminfo  *li)
     for ( sdn = slapi_get_first_suffix( &node, 0 ); sdn != NULL;
           sdn = slapi_get_next_suffix_ext( &node, 0 )) {
         be = slapi_mapping_tree_find_backend_for_sdn(sdn);
-        slapi_log_error(SLAPI_LOG_BACKLDBM, "ldbm_usn_init",
-                    "backend: %s%s\n", be->be_name, isglobal?" (global mode)":"");
         rc = usn_get_last_usn(be, &last_usn);
         if (0 == rc) { /* only when the last usn is available */
+            slapi_log_error(SLAPI_LOG_BACKLDBM, "ldbm_usn_init",
+                            "backend: %s%s\n", be->be_name, 
+                            isglobal?" (global mode)":"");
             if (isglobal) {
                 if (isfirst) {
                     li->li_global_usn_counter = slapi_counter_new();
@@ -126,7 +127,7 @@ usn_get_last_usn(Slapi_Backend *be, PRUint64 *last_usn)
     DBT value;
     PRInt64 signed_last_usn;
 
-    if (NULL == last_usn) {
+    if ((NULL == be) || (NULL == last_usn)) {
         return rc;
     }
 




More information about the 389-commits mailing list