]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-dsdb: Rework dsdb_find_dn_by_guid() to use GUID_buf_string()
authorAndrew Bartlett <abartlet@samba.org>
Wed, 25 Jan 2023 01:19:16 +0000 (14:19 +1300)
committerStefan Metzmacher <metze@samba.org>
Tue, 31 Jan 2023 12:50:32 +0000 (12:50 +0000)
This avoids a talloc_strdup() and so a failure path.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/dsdb/common/util.c

index f5de9d82cdfc60d08a0f0568d49a02d7a210888e..fb24e2a7370e0cd6bba034dcac7f67f6b5b50674 100644 (file)
@@ -3161,18 +3161,14 @@ int dsdb_find_dn_by_guid(struct ldb_context *ldb,
        int ret;
        struct ldb_result *res;
        const char *attrs[] = { NULL };
-       char *guid_str = GUID_string(mem_ctx, guid);
-
-       if (!guid_str) {
-               return ldb_operr(ldb);
-       }
+       struct GUID_txt_buf buf;
+       char *guid_str = GUID_buf_string(guid, &buf);
 
        ret = dsdb_search(ldb, mem_ctx, &res, NULL, LDB_SCOPE_SUBTREE, attrs,
                          DSDB_SEARCH_SEARCH_ALL_PARTITIONS |
                          DSDB_SEARCH_SHOW_EXTENDED_DN |
                          DSDB_SEARCH_ONE_ONLY | dsdb_flags,
                          "objectGUID=%s", guid_str);
-       talloc_free(guid_str);
        if (ret != LDB_SUCCESS) {
                return ret;
        }