소스 검색

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 [email protected] (Thank you, Rich!!)
Noriko Hosoi 11 년 전
부모
커밋
a6f66e7fcb
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      ldap/servers/slapd/back-ldbm/ldbm_usn.c

+ 4 - 3
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;
     }