From: Andrew Bartlett Date: Wed, 25 Jan 2023 01:19:16 +0000 (+1300) Subject: s4-dsdb: Rework dsdb_find_dn_by_guid() to use GUID_buf_string() X-Git-Tag: tevent-0.14.1~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d43adae855914870f82881890cb1540d679d3fb9;p=thirdparty%2Fsamba.git s4-dsdb: Rework dsdb_find_dn_by_guid() to use GUID_buf_string() This avoids a talloc_strdup() and so a failure path. Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher --- diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index f5de9d82cdf..fb24e2a7370 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -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; }