Blame SOURCES/0039-Issue-4711-SIGSEV-with-sync_repl-4738.patch

36233f
From 81e9e6431293cbdde5b037c88e5c644f39d3d14d Mon Sep 17 00:00:00 2001
36233f
From: tbordaz <tbordaz@redhat.com>
36233f
Date: Tue, 27 Apr 2021 09:29:32 +0200
36233f
Subject: [PATCH 1/2] Issue 4711 - SIGSEV with sync_repl (#4738)
36233f
36233f
Bug description:
36233f
	sync_repl sends back entries identified with a unique
36233f
	identifier that is 'nsuniqueid'. If 'nsuniqueid' is
36233f
	missing, then it may crash
36233f
36233f
Fix description:
36233f
	Check a nsuniqueid is available else returns OP_ERR
36233f
36233f
relates: https://github.com/389ds/389-ds-base/issues/4711
36233f
36233f
Reviewed by: Pierre Rogier, James Chapman, William Brown (Thanks!)
36233f
36233f
Platforms tested:  F33
36233f
---
36233f
 ldap/servers/plugins/sync/sync_util.c | 12 ++++++++++--
36233f
 1 file changed, 10 insertions(+), 2 deletions(-)
36233f
36233f
diff --git a/ldap/servers/plugins/sync/sync_util.c b/ldap/servers/plugins/sync/sync_util.c
36233f
index e64d519e1..bdba0a6c2 100644
36233f
--- a/ldap/servers/plugins/sync/sync_util.c
36233f
+++ b/ldap/servers/plugins/sync/sync_util.c
36233f
@@ -127,8 +127,8 @@ sync_create_state_control(Slapi_Entry *e, LDAPControl **ctrlp, int type, Sync_Co
36233f
     BerElement *ber;
36233f
     struct berval *bvp;
36233f
     char *uuid;
36233f
-    Slapi_Attr *attr;
36233f
-    Slapi_Value *val;
36233f
+    Slapi_Attr *attr = NULL;
36233f
+    Slapi_Value *val = NULL;
36233f
 
36233f
     if (type == LDAP_SYNC_NONE || ctrlp == NULL || (ber = der_alloc()) == NULL) {
36233f
         return (LDAP_OPERATIONS_ERROR);
36233f
@@ -138,6 +138,14 @@ sync_create_state_control(Slapi_Entry *e, LDAPControl **ctrlp, int type, Sync_Co
36233f
 
36233f
     slapi_entry_attr_find(e, SLAPI_ATTR_UNIQUEID, &attr);
36233f
     slapi_attr_first_value(attr, &val;;
36233f
+    if ((attr == NULL) || (val == NULL)) {
36233f
+        /* It may happen with entries in special backends
36233f
+         * such like cn=config, cn=shema, cn=monitor...
36233f
+         */
36233f
+        slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM,
36233f
+                      "sync_create_state_control - Entries are missing nsuniqueid. Unable to proceed.\n");
36233f
+        return (LDAP_OPERATIONS_ERROR);
36233f
+    }
36233f
     uuid = sync_nsuniqueid2uuid(slapi_value_get_string(val));
36233f
     if ((rc = ber_printf(ber, "{eo", type, uuid, 16)) != -1) {
36233f
         if (cookie) {
36233f
-- 
36233f
2.31.1
36233f