From 89059b9b6134e774ac3526f3bbc55bdf6ee08736 Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Thu, 15 Apr 2010 20:22:41 +0000
Subject: [PATCH] ITS#6473

---
 CHANGES                  |  1 +
 servers/slapd/syncrepl.c | 30 ++++++++++++++++++++----------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/CHANGES b/CHANGES
index 1341ec7b91..0efe5fb351 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,7 @@ OpenLDAP 2.4.22 Engineering
 	Fixed slapd ignore controls with unrecognized flags (ITS#6480)
 	Fixed slapd REP_ENTRY flag handling (ITS#5340)
 	Fixed slapd sasl auxprop_lookup (ITS#6441)
+	Fixed slapd syncrepl for unknown attrs and delta-sync (ITS#6473)
 	Fixed slapd-bdb contextCSN updates from updatedn (ITS#6469)
 	Fixed slapo-collect REP_ENTRY flag handling (ITS#5340,ITS#6423)
 	Fixed slapo-dynlist REP_ENTRY flag handling (ITS#5340,ITS#6423)
diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c
index 8e54357aee..526cc0e47b 100644
--- a/servers/slapd/syncrepl.c
+++ b/servers/slapd/syncrepl.c
@@ -1559,10 +1559,11 @@ static slap_verbmasks modops[] = {
 	{ BER_BVNULL, 0 }
 };
 
-static Modifications *
+static int
 syncrepl_accesslog_mods(
 	syncinfo_t *si,
-	struct berval *vals
+	struct berval *vals,
+	struct Modifications **modres
 )
 {
 	char *colon;
@@ -1571,7 +1572,7 @@ syncrepl_accesslog_mods(
 	struct berval bv, bv2;
 	short op;
 	Modifications *mod = NULL, *modlist = NULL, **modtail;
-	int i;
+	int i, rc = 0;
 
 	modtail = &modlist;
 
@@ -1588,7 +1589,13 @@ syncrepl_accesslog_mods(
 		bv.bv_len = colon - bv.bv_val;
 		if ( slap_bv2ad( &bv, &ad, &text ) ) {
 			/* Invalid */
-			continue;
+			Debug( LDAP_DEBUG_ANY, "syncrepl_accesslog_mods: %s "
+				"Invalid attribute %s, %s\n",
+				si->si_ridtxt, bv.bv_val, text );
+			slap_mods_free( modlist, 1 );
+			modlist = NULL;
+			rc = -1;
+			break;
 		}
 
 		/* Ignore dynamically generated attrs */
@@ -1633,16 +1640,18 @@ syncrepl_accesslog_mods(
 			mod->sml_numvals++;
 		}
 	}
-	return modlist;
+	*modres = modlist;
+	return rc;
 }
 
-static Modifications *
+static int
 syncrepl_changelog_mods(
 	syncinfo_t *si,
-	struct berval *vals
+	struct berval *vals,
+	struct Modifications **modres
 )
 {
-	return NULL;	/* FIXME */
+	return -1;	/* FIXME */
 }
 
 static int
@@ -1737,10 +1746,11 @@ syncrepl_message_to_op(
 		} else if ( !ber_bvstrcasecmp( &bv, &ls->ls_mod ) ) {
 			/* Parse attribute into modlist */
 			if ( si->si_syncdata == SYNCDATA_ACCESSLOG ) {
-				modlist = syncrepl_accesslog_mods( si, bvals );
+				rc = syncrepl_accesslog_mods( si, bvals, &modlist );
 			} else {
-				modlist = syncrepl_changelog_mods( si, bvals );
+				rc = syncrepl_changelog_mods( si, bvals, &modlist );
 			}
+			if ( rc ) goto done;
 		} else if ( !ber_bvstrcasecmp( &bv, &ls->ls_newRdn ) ) {
 			rdn = bvals[0];
 		} else if ( !ber_bvstrcasecmp( &bv, &ls->ls_delRdn ) ) {
-- 
GitLab