ldb:ldb_msg_remove_attr - provide a better implementation
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 3 Jun 2010 16:22:10 +0000 (18:22 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sun, 6 Jun 2010 21:13:00 +0000 (23:13 +0200)
We can have some special (bad) messages which contain multiple message elements
for the same attribute. The AD password change ones are such an example.

source4/lib/ldb/common/ldb_msg.c

index 59bd32090e5a5a6922c85a1b2e7417c271db1aa2..4d0149af8f45d77aac36fcfeb817b0ea399e3817 100644 (file)
@@ -798,8 +798,9 @@ void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element
 */
 void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr)
 {
-       struct ldb_message_element *el = ldb_msg_find_element(msg, attr);
-       if (el) {
+       struct ldb_message_element *el;
+
+       while ((el = ldb_msg_find_element(msg, attr)) != NULL) {
                ldb_msg_remove_element(msg, el);
        }
 }