>From 07b5f941afb8817c145b8fc73e91c5ea92482948 Mon Sep 17 00:00:00 2001
From: Nathan Kinder <nkinder@redhat.com>
Date: Fri, 30 Oct 2009 10:28:09 -0700
Subject: [PATCH] 387681 - Fix errors in mapping AD tombstones

The AD tombstone mapping code is not behaving correctly if a
cn contains a comma (such as a "last, first" type value).  The
code is supposed to locate the first ":" in the tombstone DN,
then scan for the first "," after that.  Everything between is
the GUID.  The problem is that the code is starting at the
beginning of the string when searching for the "," instead of
starting at the ":" that was previously found.  This causes the
"," in the cn to be found instead, which makes us fail to find
the GUID.

The fix is to simply start searching for the "," from the ":"
in the tombstone DN.
---
 .../plugins/replication/windows_protocol_util.c    |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index ed5b8a3..2c31c4f 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -2615,10 +2615,13 @@ extract_guid_from_tombstone_dn(const char *dn)
 		"CN=WDel Userdb1\\\nDEL:551706bc-ecf2-4b38-9284-9a8554171d69,CN=Deleted Objects,DC=magpie,DC=com" */
 
 	/* First find the 'DEL:' */
-	colon_offset = strchr(dn,':');
-	/* Then scan forward to the next ',' */
-	comma_offset = strchr(dn,',');
-	/* The characters inbetween are the GUID, copy them to a new string and return to the caller */
+	if (colon_offset = strchr(dn,':')) {
+		/* Then scan forward to the next ',' */
+		comma_offset = strchr(colon_offset,',');
+	}
+
+	/* The characters inbetween are the GUID, copy them
+	 * to a new string and return to the caller */
 	if (comma_offset && colon_offset && comma_offset > colon_offset) {
 		guid = slapi_ch_malloc(comma_offset - colon_offset);
 		strncpy(guid,colon_offset+1,(comma_offset-colon_offset)-1);
-- 
1.6.2.5

