diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 0438f3109770a8f05c1a806910c10fc5676640cd..3e0b8e106da011b0e189fa35ba02afdce6ea210a 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -1214,12 +1214,10 @@ static int update_ldap(const char *basedn, const char *table_name, const char *a
 	ldap_mods[0] = ast_calloc(1, sizeof(LDAPMod));
 
 	ldap_mods[0]->mod_op = LDAP_MOD_REPLACE;
-	ldap_mods[0]->mod_type = ast_calloc(sizeof(char), strlen(newparam) + 1);
-	strcpy(ldap_mods[0]->mod_type, newparam);
+	ldap_mods[0]->mod_type = ast_strdup(newparam);
 
-	ldap_mods[0]->mod_values = ast_calloc(sizeof(char), 2);
-	ldap_mods[0]->mod_values[0] = ast_calloc(sizeof(char), strlen(newval) + 1);
-	strcpy(ldap_mods[0]->mod_values[0], newval);
+	ldap_mods[0]->mod_values = ast_calloc(sizeof(char *), 2);
+	ldap_mods[0]->mod_values[0] = ast_strdup(newval);
 
 	while ((newparam = va_arg(ap, const char *))) {
 		newparam = convert_attribute_name_to_ldap(table_config, newparam);