]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: Make _internal_resolve_name() return a size_t pointer for count.
authorJeremy Allison <jra@samba.org>
Wed, 26 Aug 2020 23:42:29 +0000 (16:42 -0700)
committerNoel Power <npower@samba.org>
Mon, 7 Sep 2020 13:23:43 +0000 (13:23 +0000)
Getting closer to being a idential to the wrapper function
internal_resolve_name() which we can then remove.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/libsmb/namequery.c

index 53c1a0f63d013794e484b583a5aca2505d19b3bc..11d306f618b06d7499dadebc2d16f3b5203e71c6 100644 (file)
@@ -3184,7 +3184,7 @@ static NTSTATUS _internal_resolve_name(const char *name,
                                int name_type,
                                const char *sitename,
                                struct ip_service **return_iplist,
-                               int *return_count,
+                               size_t *return_count,
                                const char **resolve_order)
 {
        const char *tok;
@@ -3276,14 +3276,7 @@ static NTSTATUS _internal_resolve_name(const char *name,
                        TALLOC_FREE(frame);
                        return NT_STATUS_UNSUCCESSFUL;
                }
-               /* Paranoia size_t -> int. */
-               if ((int)count < 0) {
-                       SAFE_FREE(iplist);
-                       TALLOC_FREE(frame);
-                       return NT_STATUS_INVALID_PARAMETER;
-               }
-
-               *return_count = (int)count;
+               *return_count = count;
                *return_iplist = iplist;
                TALLOC_FREE(frame);
                return NT_STATUS_OK;
@@ -3474,12 +3467,6 @@ static NTSTATUS _internal_resolve_name(const char *name,
                DEBUG(10, ("\n"));
        }
 
-       /*
-        * The below can't go negative, we checked
-        * above with icount which must always be greater
-        * than ret_count, we only subtract addresses,
-        * not add them.
-        */
        *return_count = ret_count;
        *return_iplist = iplist;
 
@@ -3502,7 +3489,7 @@ NTSTATUS internal_resolve_name(TALLOC_CTX *ctx,
 {
        struct ip_service *iplist_malloc = NULL;
        struct ip_service *iplist = NULL;
-       int count = 0;
+       size_t count = 0;
        NTSTATUS status;
 
        status = _internal_resolve_name(name,
@@ -3516,12 +3503,6 @@ NTSTATUS internal_resolve_name(TALLOC_CTX *ctx,
                return status;
        }
 
-       /* Paranoia. */
-       if (count < 0) {
-               SAFE_FREE(iplist_malloc);
-               return NT_STATUS_INVALID_PARAMETER;
-       }
-
        status = dup_ip_service_array(ctx,
                                &iplist,
                                iplist_malloc,
@@ -3530,7 +3511,7 @@ NTSTATUS internal_resolve_name(TALLOC_CTX *ctx,
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
-       *ret_count = (size_t)count;
+       *ret_count = count;
        *return_iplist = iplist;
        return NT_STATUS_OK;
 }