s3: libsmb: Move all calls to convert_ss2service() to one place now all methods retur...
authorJeremy Allison <jra@samba.org>
Tue, 21 Jul 2020 03:52:58 +0000 (20:52 -0700)
committerIsaac Boukris <iboukris@sn-devel-184>
Tue, 4 Aug 2020 10:13:53 +0000 (10:13 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
Autobuild-User(master): Isaac Boukris <iboukris@samba.org>
Autobuild-Date(master): Tue Aug  4 10:13:53 UTC 2020 on sn-devel-184

source3/libsmb/namequery.c

index f7664d4817e588bbf83ea3153516b06089ac1b66..0e87df296907cd6152a664867507b21ec8deac38 100644 (file)
@@ -2850,13 +2850,6 @@ NTSTATUS internal_resolve_name(const char *name,
                        if (!NT_STATUS_IS_OK(status)) {
                                continue;
                        }
-                       ok = convert_ss2service(return_iplist,
-                                               ss_list,
-                                               return_count);
-                       if (!ok) {
-                               status = NT_STATUS_NO_MEMORY;
-                               goto fail;
-                       }
                        goto done;
                } else if(strequal( tok, "kdc")) {
                        /* deal with KDC_NAME_TYPE names here.
@@ -2873,12 +2866,6 @@ NTSTATUS internal_resolve_name(const char *name,
                        /* Ensure we don't namecache
                         * this with the KDC port. */
                        name_type = KDC_NAME_TYPE;
-                       ok = convert_ss2service(return_iplist,
-                                               ss_list,
-                                               return_count);
-                       if (!ok) {
-                               status = NT_STATUS_NO_MEMORY;
-                       }
                        goto done;
                } else if(strequal( tok, "ads")) {
                        /* deal with 0x1c and 0x1b names here.
@@ -2892,12 +2879,6 @@ NTSTATUS internal_resolve_name(const char *name,
                        if (!NT_STATUS_IS_OK(status)) {
                                continue;
                        }
-                       ok = convert_ss2service(return_iplist,
-                                               ss_list,
-                                               return_count);
-                       if (!ok) {
-                               status = NT_STATUS_NO_MEMORY;
-                       }
                        goto done;
                } else if (strequal(tok, "lmhosts")) {
                        status = resolve_lmhosts_file_as_sockaddr(
@@ -2910,13 +2891,6 @@ NTSTATUS internal_resolve_name(const char *name,
                        if (!NT_STATUS_IS_OK(status)) {
                                continue;
                        }
-                       ok = convert_ss2service(return_iplist,
-                                               ss_list,
-                                               return_count);
-                       if (!ok) {
-                               status = NT_STATUS_NO_MEMORY;
-                               goto fail;
-                       }
                        goto done;
                } else if (strequal(tok, "wins")) {
                        /* don't resolve 1D via WINS */
@@ -2931,13 +2905,6 @@ NTSTATUS internal_resolve_name(const char *name,
                        if (!NT_STATUS_IS_OK(status)) {
                                continue;
                        }
-                       ok = convert_ss2service(return_iplist,
-                                               ss_list,
-                                               return_count);
-                       if (!ok) {
-                               status = NT_STATUS_NO_MEMORY;
-                               goto fail;
-                       }
                        goto done;
                } else if (strequal(tok, "bcast")) {
                        status = name_resolve_bcast(
@@ -2949,13 +2916,6 @@ NTSTATUS internal_resolve_name(const char *name,
                        if (!NT_STATUS_IS_OK(status)) {
                                continue;
                        }
-                       ok = convert_ss2service(return_iplist,
-                                               ss_list,
-                                               return_count);
-                       if (!ok) {
-                               status = NT_STATUS_NO_MEMORY;
-                               goto fail;
-                       }
                        goto done;
                } else {
                        DBG_ERR("unknown name switch type %s\n",
@@ -2965,8 +2925,6 @@ NTSTATUS internal_resolve_name(const char *name,
 
        /* All of the resolve_* functions above have returned false. */
 
-  fail:
-
        TALLOC_FREE(frame);
        SAFE_FREE(*return_iplist);
        *return_count = 0;
@@ -2975,6 +2933,14 @@ NTSTATUS internal_resolve_name(const char *name,
 
   done:
 
+       ok = convert_ss2service(return_iplist, ss_list, return_count);
+       if (!ok) {
+               TALLOC_FREE(frame);
+               SAFE_FREE(*return_iplist);
+               *return_count = 0;
+               return NT_STATUS_NO_MEMORY;
+       }
+
        /* Remove duplicate entries.  Some queries, notably #1c (domain
        controllers) return the PDC in iplist[0] and then all domain
        controllers including the PDC in iplist[1..n].  Iterating over