]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: namequery - Add internal_resolve_name_talloc().
authorJeremy Allison <jra@samba.org>
Wed, 26 Aug 2020 20:25:07 +0000 (13:25 -0700)
committerNoel Power <npower@samba.org>
Mon, 7 Sep 2020 13:23:41 +0000 (13:23 +0000)
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 <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/libsmb/namequery.c
source3/libsmb/namequery.h

index 11e2605bb85ff04469ecf0e90a0897e13dde231a..7af3151a561242ba3f04a8b02c65218205def545 100644 (file)
@@ -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
index d38e0efe3c160bb1fffa6897fecd68b809521bd4..1579942c36b646fa7732f1d01265e1443c7eab18 100644 (file)
@@ -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,