The branch, master has been updated
       via  08c4dd586fc libsmb: Fix CID 1467087: Resource leaks
       via  c6a11d8dcda libsmb: Use talloc_realloc() correctly in 
resolve_hosts()
       via  a3572821530 libsmb: Protect against rogue getaddrinfo result
       via  ed263ef47cf libsmb: README.Coding for resolve_hosts()
       via  8e31c4e69c2 libsmb: Use direct struct initialization
      from  454ccd986b6 s3: fix fcntl waf configure check

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 08c4dd586fc69051ab121071a95d6e18f85c290b
Author: Volker Lendecke <[email protected]>
Date:   Tue Sep 22 13:55:19 2020 +0200

    libsmb: Fix CID 1467087: Resource leaks
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Wed Sep 23 18:20:36 UTC 2020 on sn-devel-184

commit c6a11d8dcda60e0854b6cd667a4f40a057256eb7
Author: Volker Lendecke <[email protected]>
Date:   Tue Sep 22 13:52:57 2020 +0200

    libsmb: Use talloc_realloc() correctly in resolve_hosts()
    
    On realloc failure the old value is still around
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit a3572821530063b842da26af29babfca8c51b4cc
Author: Volker Lendecke <[email protected]>
Date:   Tue Sep 22 13:50:01 2020 +0200

    libsmb: Protect against rogue getaddrinfo result
    
    Probably a "won't happen", but to me this looked fishy
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit ed263ef47cf754e38a92cf600006e1a6b2f21b36
Author: Volker Lendecke <[email protected]>
Date:   Tue Sep 22 13:49:10 2020 +0200

    libsmb: README.Coding for resolve_hosts()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 8e31c4e69c24445d5bb961c5e476f99478f0e577
Author: Volker Lendecke <[email protected]>
Date:   Tue Sep 22 13:47:45 2020 +0200

    libsmb: Use direct struct initialization
    
    Give the compiler more hints
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/libsmb/namequery.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index bf53e01bfb7..cd4a31fd8c9 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -2818,13 +2818,15 @@ static NTSTATUS resolve_hosts(TALLOC_CTX *mem_ctx,
        }
 
        for (res = ailist; res; res = res->ai_next) {
-               struct sockaddr_storage ss;
+               struct sockaddr_storage ss = {0};
+               struct sockaddr_storage *tmp = NULL;
 
-               if (!res->ai_addr || res->ai_addrlen == 0) {
+               if ((res->ai_addr == NULL) ||
+                   (res->ai_addrlen == 0) ||
+                   (res->ai_addrlen > sizeof(ss))) {
                        continue;
                }
 
-               ZERO_STRUCT(ss);
                memcpy(&ss, res->ai_addr, res->ai_addrlen);
 
                if (is_zero_addr(&ss)) {
@@ -2834,18 +2836,21 @@ static NTSTATUS resolve_hosts(TALLOC_CTX *mem_ctx,
                /* wrap check. */
                if (ret_count + 1 < ret_count) {
                        freeaddrinfo(ailist);
+                       TALLOC_FREE(iplist);
                        return NT_STATUS_INVALID_PARAMETER;
                }
                ret_count += 1;
 
-               iplist = talloc_realloc(
+               tmp = talloc_realloc(
                        mem_ctx, iplist, struct sockaddr_storage,
                        ret_count);
-               if (iplist == NULL) {
+               if (tmp == NULL) {
                        DEBUG(3,("resolve_hosts: malloc fail !\n"));
                        freeaddrinfo(ailist);
+                       TALLOC_FREE(iplist);
                        return NT_STATUS_NO_MEMORY;
                }
+               iplist = tmp;
                iplist[i] = ss;
                i++;
        }


-- 
Samba Shared Repository

Reply via email to