]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb-samba:ldif_handlers: dn_link_comparison: sort invalid DNs
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 11 Apr 2024 06:08:54 +0000 (18:08 +1200)
committerJule Anger <janger@samba.org>
Mon, 10 Jun 2024 13:25:17 +0000 (13:25 +0000)
If both DNs are invalid, we can say they are equal.

This means invalid or NULL DNs will sort to the end of the array,
before deleted DNs:

[ valid DNs, sorted | invalid/NULL DNs | deleted DNs, sorted ]

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 7280c8e53f463108fe3de443ce63572dde689a30)

lib/ldb-samba/ldif_handlers.c

index 90973cbf3c30c76f2f3fd333267a5405f214dc91..e339c1c8b1050152f47c8ef6329f123b8faaa9d8 100644 (file)
@@ -1179,12 +1179,18 @@ static int samba_ldb_dn_link_comparison(struct ldb_context *ldb, void *mem_ctx,
        }
 
        dn1 = ldb_dn_from_ldb_val(mem_ctx, ldb, v1);
+       dn2 = ldb_dn_from_ldb_val(mem_ctx, ldb, v2);
+
        if ( ! ldb_dn_validate(dn1)) {
                TALLOC_FREE(dn1);
+               if ( ! ldb_dn_validate(dn2)) {
+                       TALLOC_FREE(dn2);
+                       return 0;
+               }
+               TALLOC_FREE(dn2);
                return 1;
        }
 
-       dn2 = ldb_dn_from_ldb_val(mem_ctx, ldb, v2);
        if ( ! ldb_dn_validate(dn2)) {
                TALLOC_FREE(dn1);
                TALLOC_FREE(dn2);