From: Jeremy Allison Date: Wed, 26 Aug 2020 20:25:07 +0000 (-0700) Subject: s3: libsmb: namequery - Add internal_resolve_name_talloc(). X-Git-Tag: talloc-2.3.2~609 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6fc75a73bd630f03842e9a39805d58c59422ce3;p=thirdparty%2Fsamba.git s3: libsmb: namequery - Add internal_resolve_name_talloc(). This is a wrapper function for internal_resolve_name() that converts the replies from malloc() -> talloc(). Now to move the callers, and I can move the talloc code down one level again. Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 11e2605bb85..7af3151a561 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -3415,6 +3415,55 @@ NTSTATUS internal_resolve_name(const char *name, return status; } +/******************************************************** + Wrapper function for internal_resolve_name() that returns + talloc'ed memory. Eventually this will be the only version + and then we can rename it to internal_resolve_name(). +********************************************************/ + +NTSTATUS internal_resolve_name_talloc(TALLOC_CTX *ctx, + const char *name, + int name_type, + const char *sitename, + struct ip_service **return_iplist, + size_t *ret_count, + const char **resolve_order) +{ + struct ip_service *iplist_malloc = NULL; + struct ip_service *iplist = NULL; + int count = 0; + NTSTATUS status; + + status = internal_resolve_name(name, + name_type, + sitename, + &iplist_malloc, + &count, + resolve_order); + if (!NT_STATUS_IS_OK(status)) { + SAFE_FREE(iplist_malloc); + return status; + } + + /* Paranoia. */ + if (count < 0) { + SAFE_FREE(iplist_malloc); + return NT_STATUS_INVALID_PARAMETER; + } + + status = dup_ip_service_array(ctx, + &iplist, + iplist_malloc, + count); + SAFE_FREE(iplist_malloc); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + *ret_count = (size_t)count; + *return_iplist = iplist; + return NT_STATUS_OK; +} + /******************************************************** Internal interface to resolve a name into one IP address. Use this function if the string is either an IP address, DNS diff --git a/source3/libsmb/namequery.h b/source3/libsmb/namequery.h index d38e0efe3c1..1579942c36b 100644 --- a/source3/libsmb/namequery.h +++ b/source3/libsmb/namequery.h @@ -98,6 +98,13 @@ NTSTATUS internal_resolve_name(const char *name, struct ip_service **return_iplist, int *return_count, const char **resolve_order); +NTSTATUS internal_resolve_name_talloc(TALLOC_CTX *ctx, + const char *name, + int name_type, + const char *sitename, + struct ip_service **return_iplist, + size_t *ret_count, + const char **resolve_order); bool resolve_name(const char *name, struct sockaddr_storage *return_ss, int name_type,