The branch, master has been updated
       via  80d72b532f6 smbd: Make an if-statement in ReadDirName() a bit more 
readable
       via  202a8a53b48 smbclient: strequal() -> ISDOT/ISDOTDOT
       via  a0c897ba201 smbd: Use ISDOT/ISDOTDOT in ReadDirName()
       via  3505285c8f2 smbd: Fix a misleading comment
       via  bd692c1f904 smbd: Avoid an "else"
       via  393176e9675 lib: Use talloc_zero, save a ZERO_STRUCT
       via  3353174d1a0 lib: Add a pair of {}
       via  313d207d724 lib: Slightly simplify add_interface()
       via  280e9191cbf smbd: Make non_widelink_open() robust for non-cwd dirfsp
      from  dbde99a0305 replace: add explicit function pointer casting from 
dlsym() to avoid warnings

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


- Log -----------------------------------------------------------------
commit 80d72b532f6c17acc045fcdada71dbbc0adb977a
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Mar 12 12:47:03 2022 +0100

    smbd: Make an if-statement in ReadDirName() a bit more readable
    
    Align to make the () structure more obvious
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Wed Mar 23 17:53:09 UTC 2022 on sn-devel-184

commit 202a8a53b48e599e6e9a2a65f52b0a9667ef9df7
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Mar 12 12:40:29 2022 +0100

    smbclient: strequal() -> ISDOT/ISDOTDOT
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit a0c897ba2011a36f7dfbf55ead327092373c5020
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Mar 12 12:47:54 2022 +0100

    smbd: Use ISDOT/ISDOTDOT in ReadDirName()
    
    With those macros, we check n[0] twice now, but I think the compiler
    should either optimize that out or if it can't this will be in the CPU
    cache, so the second check should be practially free. I can't imagine
    this makes any difference but the better readability.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 3505285c8f2af3d69a3bf0b2b97c1af38cc0688c
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 13 15:22:50 2022 +0100

    smbd: Fix a misleading comment
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit bd692c1f9045880b19fbc6de9ed024d06c1c8113
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 13 15:58:03 2022 +0100

    smbd: Avoid an "else"
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 393176e967579655b55a429c35ab6b399ff8cc07
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Mar 21 09:13:09 2022 +0100

    lib: Use talloc_zero, save a ZERO_STRUCT
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 3353174d1a07c01b57a787ee458965352c3819d5
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Mar 21 09:12:44 2022 +0100

    lib: Add a pair of {}
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 313d207d72477370f2d06e8d5bb8662e7f4d2176
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Mar 21 09:12:02 2022 +0100

    lib: Slightly simplify add_interface()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 280e9191cbf8a766e69ab138450f2beccbedd879
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Mar 9 12:58:40 2022 +0100

    smbd: Make non_widelink_open() robust for non-cwd dirfsp
    
    If you pass in dirfsp!=conn->cwd_fsp and a stream fsp, we don't chdir
    to the parent pathname, and thus we also don't overwrite
    fsp->base_fsp.
    
    fsp->base_fsp!=NULL is thus the wrong condition to restore the
    original base fsp name: If we open a stream with a non-cwd_fsp dirfsp,
    we would overwrite fsp->base_fsp->fsp_name with NULL.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

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

Summary of changes:
 source3/client/client.c        | 12 ++++++------
 source3/smbd/dir.c             | 19 ++++++++++---------
 source3/smbd/open.c            |  3 ++-
 source4/lib/socket/interface.c | 11 +++++++----
 4 files changed, 25 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index 690f9deaec9..15e32d379f0 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -565,9 +565,9 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, 
struct file_info *fin
                uint16_t fnum;
                struct cli_credentials *creds = samba_cmdline_get_creds();
 
-               /* skip if this is . or .. */
-               if ( strequal(finfo->name,"..") || strequal(finfo->name,".") )
+               if (ISDOT(finfo->name) || ISDOTDOT(finfo->name)) {
                        return NT_STATUS_OK;
+               }
                /* create absolute filename for cli_ntcreate() FIXME */
                afname = talloc_asprintf(ctx,
                                        "%s%s%s",
@@ -1214,8 +1214,9 @@ static NTSTATUS do_mget(struct cli_state *cli_state, 
struct file_info *finfo,
                return NT_STATUS_OK;
        }
 
-       if (strequal(finfo->name,".") || strequal(finfo->name,".."))
+       if (ISDOT(finfo->name) || ISDOTDOT(finfo->name)) {
                return NT_STATUS_OK;
+       }
 
        if ((finfo->attr & FILE_ATTRIBUTE_DIRECTORY) && !recurse) {
                return NT_STATUS_OK;
@@ -2077,10 +2078,9 @@ static int file_find(TALLOC_CTX *ctx,
                return -1;
 
         while ((dname = readdirname(dir))) {
-               if (!strcmp("..", dname))
-                       continue;
-               if (!strcmp(".", dname))
+               if (ISDOT(dname) || ISDOTDOT(dname)) {
                        continue;
+               }
 
                path = talloc_asprintf(ctx, "%s/%s", directory, dname);
                if (path == NULL) {
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 059de584d17..65997dd3099 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -507,7 +507,8 @@ static char *dptr_ReadDirName(TALLOC_CTX *ctx,
        if (NT_STATUS_IS_OK(status)) {
                name = found_name;
                goto clean;
-       } else if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+       }
+       if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
                /* The case-insensitive lookup was authoritative. */
                goto clean;
        }
@@ -1506,8 +1507,9 @@ NTSTATUS OpenDir(TALLOC_CTX *mem_ctx,
        }
 
        /*
-        * This overwrites the destructor set by smb_Dir_OpenDir_destructor(),
-        * but smb_Dir_OpenDir_destructor() calls the OpenDir_fsp() destructor.
+        * This overwrites the destructor set by OpenDir_fsp() but
+        * smb_Dir_OpenDir_destructor() calls the OpenDir_fsp()
+        * destructor.
         */
        talloc_set_destructor(dir_hnd, smb_Dir_OpenDir_destructor);
 
@@ -1601,7 +1603,8 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, long 
*poffset,
 
        /* Cheat to allow . and .. to be the first entries returned. */
        if (((*poffset == START_OF_DIRECTORY_OFFSET) ||
-            (*poffset == DOT_DOT_DIRECTORY_OFFSET)) && (dir_hnd->file_number < 
2))
+            (*poffset == DOT_DOT_DIRECTORY_OFFSET)) &&
+           (dir_hnd->file_number < 2))
        {
                if (dir_hnd->file_number == 0) {
                        n = ".";
@@ -1625,11 +1628,9 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, long 
*poffset,
 
        while ((n = vfs_readdirname(conn, dir_hnd->fsp, dir_hnd->dir, sbuf, 
&talloced))) {
                /* Ignore . and .. - we've already returned them. */
-               if (*n == '.') {
-                       if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
-                               TALLOC_FREE(talloced);
-                               continue;
-                       }
+               if (ISDOT(n) || ISDOTDOT(n)) {
+                       TALLOC_FREE(talloced);
+                       continue;
                }
                *poffset = dir_hnd->offset = SMB_VFS_TELLDIR(conn, 
dir_hnd->dir);
                *ptalloced = talloced;
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index d01b5ae65f4..3995a0beb35 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -891,7 +891,8 @@ static NTSTATUS non_widelink_open(const struct files_struct 
*dirfsp,
 
   out:
        fsp->fsp_name = orig_fsp_name;
-       if (fsp->base_fsp != NULL) {
+
+       if (orig_base_fsp_name != NULL) {
                /* Save off the temporary name. */
                struct smb_filename *base_smb_fname_rel =
                        fsp->base_fsp->fsp_name;
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index 181893a9e7f..65543c6a294 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -94,11 +94,14 @@ static void add_interface(TALLOC_CTX *mem_ctx, const struct 
iface_struct *ifs, s
                return;
        }
 
-       iface = talloc(*interfaces == NULL ? mem_ctx : *interfaces, struct 
interface);
-       if (iface == NULL) 
+       if (*interfaces != NULL) {
+               mem_ctx = *interfaces;
+       }
+
+       iface = talloc_zero(mem_ctx, struct interface);
+       if (iface == NULL) {
                return;
-       
-       ZERO_STRUCTPN(iface);
+       }
 
        iface->name = talloc_strdup(iface, ifs->name);
        if (!iface->name) {


-- 
Samba Shared Repository

Reply via email to