dsdb mods/extended_dn_out: remove element using ldb_msg api
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 10 Apr 2019 04:37:23 +0000 (16:37 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 10 May 2019 01:15:17 +0000 (01:15 +0000)
The bare memmove is not strictly safe at the end of the list.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/extended_dn_out.c

index ee94be4f92864480c87235f7600be0cfa6e35376..4228a2ab69df2576aed464eff61e44317e9ceeb3 100644 (file)
@@ -654,10 +654,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
                if (msg->elements[i].num_values == 0) {
                        /* we've deleted all of the values from this
                         * element - remove the element */
-                       memmove(&msg->elements[i],
-                               &msg->elements[i+1],
-                               (msg->num_elements-(i+1))*sizeof(struct ldb_message_element));
-                       msg->num_elements--;
+                       ldb_msg_remove_element(msg, &msg->elements[i]);
                        i--;
                }
        }