[asterisk-commits] res config ldap: Fix erroneous LDAP MOD REPLACE in LDAP modify (asterisk[14])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 21 17:10:55 CST 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5009 )

Change subject: res_config_ldap: Fix erroneous LDAP_MOD_REPLACE in LDAP modify
......................................................................


res_config_ldap: Fix erroneous LDAP_MOD_REPLACE in LDAP modify

We always treat the first change of our modification batch as a
replacement when it sometimes is actually a delete. So we have to pass
the correct arguments to the OpenLDAP library.

ASTERISK-26580 #close
Reported by: Nicholas John Koch
Patches:
	res_config_ldap.c-11.24.1.patch (license #6833) patch uploaded
	by Nicholas John Koch

Change-Id: I0741d25de07c9539f1edc6eff3696165dfb64fbe
---
M res/res_config_ldap.c
1 file changed, 7 insertions(+), 4 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 8454273..48df96b 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -1294,12 +1294,15 @@
 	mods_size = 2; /* one for the first param/value pair and one for the the terminating NULL */
 	ldap_mods = ldap_memcalloc(sizeof(LDAPMod *), mods_size);
 	ldap_mods[0] = ldap_memcalloc(1, sizeof(LDAPMod));
-
-	ldap_mods[0]->mod_op = LDAP_MOD_REPLACE;
 	ldap_mods[0]->mod_type = ldap_strdup(newparam);
 
-	ldap_mods[0]->mod_values = ast_calloc(sizeof(char *), 2);
-	ldap_mods[0]->mod_values[0] = ldap_strdup(field->value);
+	if (strlen(field->value) == 0) {
+		ldap_mods[0]->mod_op = LDAP_MOD_DELETE;
+	} else {
+		ldap_mods[0]->mod_op = LDAP_MOD_REPLACE;
+		ldap_mods[0]->mod_values = ast_calloc(sizeof(char *), 2);
+		ldap_mods[0]->mod_values[0] = ldap_strdup(field->value);
+	}
 
 	while ((field = field->next)) {
 		newparam = convert_attribute_name_to_ldap(table_config, field->name);

-- 
To view, visit https://gerrit.asterisk.org/5009
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0741d25de07c9539f1edc6eff3696165dfb64fbe
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list