From ad54cec94e9f27c6664a083ecd6d885090151939 Mon Sep 17 00:00:00 2001 From: martinh Date: Wed, 28 Jul 2010 10:06:19 +0000 Subject: [PATCH] Revert parts of previous change leading to assertion failure for certain modify operations. Also fix logic error when replacing an attribute with the empty set. --- usr.sbin/ldapd/modify.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/usr.sbin/ldapd/modify.c b/usr.sbin/ldapd/modify.c index 61c168b1cdf..02e0820cfda 100644 --- a/usr.sbin/ldapd/modify.c +++ b/usr.sbin/ldapd/modify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modify.c,v 1.13 2010/07/13 12:54:51 martinh Exp $ */ +/* $OpenBSD: modify.c,v 1.14 2010/07/28 10:06:19 martinh Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk @@ -258,7 +258,7 @@ ldap_modify(struct request *req) } for (mod = mods->be_sub; mod; mod = mod->be_next) { - if (ber_scanf_elements(mod, "{E{ese", &op, &prev, &attr, &vals) != 0) { + if (ber_scanf_elements(mod, "{E{ese(", &op, &prev, &attr, &vals) != 0) { rc = LDAP_PROTOCOL_ERROR; vals = NULL; goto done; @@ -289,7 +289,7 @@ ldap_modify(struct request *req) if (ldap_add_attribute(entry, attr, vals) != NULL) vals = NULL; } else { - if (ldap_merge_values(a, vals->be_sub) == 0) + if (ldap_merge_values(a, vals) == 0) vals = NULL; } break; @@ -301,15 +301,16 @@ ldap_modify(struct request *req) ldap_del_attribute(entry, attr); break; case LDAP_MOD_REPLACE: - if (vals->be_sub != NULL) { + if (vals->be_sub != NULL && + vals->be_sub->be_type != BER_TYPE_EOC) { if (a == NULL) { if (ldap_add_attribute(entry, attr, vals) != NULL) vals = NULL; } else { - if (ldap_set_values(a, vals->be_sub) == 0) + if (ldap_set_values(a, vals) == 0) vals = NULL; } - } else if (a == NULL) + } else if (a != NULL) ldap_del_attribute(entry, attr); break; } -- 2.20.1