The branch, master has been updated
       via  a4f2b8daee9 vfs: Move reparse point functions to util_reparse.c
       via  1cb17b5472b ldb: Avoid a cast (unsigned long long) in ldbmodify.c
       via  0c18e2fdd49 lib: Remove an unused macro
       via  9f7791a909a libsmb: Add overflow protection to 
symlink_reparse_buffer_marshall()
       via  10d883105a0 libcli: Add tevent_req_received() calls to 
smb2cli_create_recv()
       via  c751c710620 libcli: Move IO_REPARSE_TAG definitions to 
smb_constants.h
       via  7e73527ad35 libcli: Slightly simplify smb2cli_req_recv() with an 
early return
       via  d304341ea39 smbd: Apply a bit of README.Coding to unix_convert()
       via  1943e967a06 smbd: Reduce indentation in check_reduced_name()
       via  1e7ff44fd46 lib: Move a #define ip_equal_v4() to nmbd/nmbd.h
       via  38814784cf0 smbd: Fix typos
       via  b654f2565b0 tsocket: Fix a typo
       via  86008f5e6f2 net: Align integer types
      from  d827392f2ab replmd: slightly clarify a comment

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


- Log -----------------------------------------------------------------
commit a4f2b8daee9b54e68a6c46d029bba4c1578aaf21
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 11 15:15:02 2020 +0200

    vfs: Move reparse point functions to util_reparse.c
    
    Shamelessly copied from from Jeremy's smb2-unix branch :-)
    
    No change in behaviour, but we will have to cope with reparse points in the
    future.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Mon Jun 15 19:25:40 UTC 2020 on sn-devel-184

commit 1cb17b5472b18572d14a52a0c9ddb8064322a383
Author: Volker Lendecke <[email protected]>
Date:   Mon Jun 15 12:32:36 2020 +0200

    ldb: Avoid a cast (unsigned long long) in ldbmodify.c
    
    We have %zu for size_t
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 0c18e2fdd491736190cfdff3f51733c5c6e6b309
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 11 14:49:58 2020 +0200

    lib: Remove an unused macro
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 9f7791a909a17bfbeaa06145d803654b76441d3f
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 11 14:42:49 2020 +0200

    libsmb: Add overflow protection to symlink_reparse_buffer_marshall()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 10d883105a02c49c86a7a79020337c1f8b419afb
Author: Volker Lendecke <[email protected]>
Date:   Tue Jun 9 18:54:07 2020 +0200

    libcli: Add tevent_req_received() calls to smb2cli_create_recv()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit c751c710620686c01eefbe83245d6fdbdc47cd32
Author: Volker Lendecke <[email protected]>
Date:   Tue Jun 9 17:18:35 2020 +0200

    libcli: Move IO_REPARSE_TAG definitions to smb_constants.h
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 7e73527ad3523efa4ce24e92a2cd194b59967852
Author: Volker Lendecke <[email protected]>
Date:   Tue Jun 9 16:15:46 2020 +0200

    libcli: Slightly simplify smb2cli_req_recv() with an early return
    
    One if-condition less
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit d304341ea398d12d1f530b01b7e12e4839d23dab
Author: Volker Lendecke <[email protected]>
Date:   Mon Jun 15 12:16:36 2020 +0200

    smbd: Apply a bit of README.Coding to unix_convert()
    
    Looking at that more closely right now...
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 1943e967a06ee83c7fed36280f8577f6245fb266
Author: Volker Lendecke <[email protected]>
Date:   Fri Jun 12 11:36:56 2020 +0200

    smbd: Reduce indentation in check_reduced_name()
    
    No change in behaviour.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 1e7ff44fd46f34e1df50bb7c55334b0ed5501d18
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 11 14:48:48 2020 +0200

    lib: Move a #define ip_equal_v4() to nmbd/nmbd.h
    
    It's only used there
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 38814784cf004a77e7bf4bf17854b1b47570ef61
Author: Volker Lendecke <[email protected]>
Date:   Sat Jun 13 15:32:31 2020 +0200

    smbd: Fix typos
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit b654f2565b0ffca56c13ff24000f8c606253011e
Author: Volker Lendecke <[email protected]>
Date:   Sun Jun 14 16:36:23 2020 +0200

    tsocket: Fix a typo
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 86008f5e6f28d7c9d756ddf25f7aaf119378b52e
Author: Volker Lendecke <[email protected]>
Date:   Sun Jun 14 10:45:39 2020 +0200

    net: Align integer types
    
    "i" is used to loop over an int as well. Introduce an int helper
    variable that is autoconverted without warnings
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

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

Summary of changes:
 lib/ldb/tools/ldbmodify.c                          |  9 +-
 lib/tsocket/tsocket_guide.txt                      |  2 +-
 libcli/smb/smb2cli_create.c                        |  2 +
 libcli/smb/smbXcli_base.c                          |  7 +-
 libcli/smb/smb_constants.h                         | 16 ++++
 source3/include/ntioctl.h                          |  9 --
 source3/include/smb_macros.h                       | 13 ---
 source3/libsmb/reparse_symlink.c                   | 10 ++-
 source3/modules/util_reparse.c                     | 50 +++++++++++
 .../srv_epmapper.h => modules/util_reparse.h}      | 37 ++++-----
 source3/modules/vfs_default.c                      | 20 +++--
 source3/modules/wscript_build                      |  6 +-
 source3/nmbd/nmbd.h                                |  6 ++
 source3/smbd/filename.c                            | 39 +++++----
 source3/smbd/vfs.c                                 | 97 +++++++++++-----------
 source3/utils/net_ads.c                            |  6 +-
 16 files changed, 203 insertions(+), 126 deletions(-)
 create mode 100644 source3/modules/util_reparse.c
 copy source3/{rpc_server/epmapper/srv_epmapper.h => modules/util_reparse.h} 
(54%)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/tools/ldbmodify.c b/lib/ldb/tools/ldbmodify.c
index 9b4d7b7d917..73df41787e2 100644
--- a/lib/ldb/tools/ldbmodify.c
+++ b/lib/ldb/tools/ldbmodify.c
@@ -107,10 +107,13 @@ static int process_file(struct ldb_context *ldb, FILE *f, 
unsigned int *count)
                        if (errstr == NULL) {
                                errstr = ldb_errstring(ldb);
                        }
-                       fprintf(stderr, "ERR: (%s) \"%s\" on DN %s at block 
before line %llu\n",
+                       fprintf(stderr,
+                               "ERR: (%s) \"%s\" on DN %s at block before "
+                               "line %zu\n",
                                ldb_strerror(ret),
-                               errstr, ldb_dn_get_linearized(ldif->msg->dn), 
-                               (unsigned long long)state.line_no);
+                               errstr,
+                               ldb_dn_get_linearized(ldif->msg->dn),
+                               state.line_no);
                        fun_ret = ret;
                } else {
                        (*count)++;
diff --git a/lib/tsocket/tsocket_guide.txt b/lib/tsocket/tsocket_guide.txt
index 45e20b5103a..9a96b0432bd 100644
--- a/lib/tsocket/tsocket_guide.txt
+++ b/lib/tsocket/tsocket_guide.txt
@@ -128,7 +128,7 @@ functions similar to the readv(2)/writev(2)/close(2) 
syscalls.
 The tstream_pending_bytes() function is able to report how many bytes of
 the incoming stream have been received but have not been consumed yet.
 It returns -1 and sets 'errno' on failure.
-Otherwise it returns the number of uncomsumed bytes (it can return 0!).
+Otherwise it returns the number of unconsumed bytes (it can return 0!).
 
   ssize_t tstream_pending_bytes(struct tstream_context *stream);
 
diff --git a/libcli/smb/smb2cli_create.c b/libcli/smb/smb2cli_create.c
index 778b501fae7..325bc79f9cd 100644
--- a/libcli/smb/smb2cli_create.c
+++ b/libcli/smb/smb2cli_create.c
@@ -249,6 +249,7 @@ NTSTATUS smb2cli_create_recv(struct tevent_req *req,
        NTSTATUS status;
 
        if (tevent_req_is_nterror(req, &status)) {
+               tevent_req_received(req);
                return status;
        }
        *fid_persistent = state->fid_persistent;
@@ -260,6 +261,7 @@ NTSTATUS smb2cli_create_recv(struct tevent_req *req,
                blobs->num_blobs = state->blobs.num_blobs;
                blobs->blobs = talloc_move(mem_ctx, &state->blobs.blobs);
        }
+       tevent_req_received(req);
        return NT_STATUS_OK;
 }
 
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 895fa64fcf5..3e5bee92ed1 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -4012,15 +4012,10 @@ NTSTATUS smb2cli_req_recv(struct tevent_req *req, 
TALLOC_CTX *mem_ctx,
        if (tevent_req_is_nterror(req, &status)) {
                for (i=0; i < num_expected; i++) {
                        if (NT_STATUS_EQUAL(status, expected[i].status)) {
-                               found_status = true;
-                               break;
+                               return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
                        }
                }
 
-               if (found_status) {
-                       return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
-               }
-
                return status;
        }
 
diff --git a/libcli/smb/smb_constants.h b/libcli/smb/smb_constants.h
index 07c22209881..ee350d14154 100644
--- a/libcli/smb/smb_constants.h
+++ b/libcli/smb/smb_constants.h
@@ -582,4 +582,20 @@ enum csc_policy {
        (FSCTL_NETWORK_FILESYSTEM | FSCTL_ACCESS_ANY | 0x0200 | 
FSCTL_METHOD_BUFFERED)
 #define FSCTL_VALIDATE_NEGOTIATE_INFO  (FSCTL_NETWORK_FILESYSTEM | 
FSCTL_ACCESS_ANY | 0x0204 | FSCTL_METHOD_BUFFERED)
 
+/*
+ * A few values from [MS-FSCC] 2.1.2.1 Reparse Tags
+ */
+
+#define IO_REPARSE_TAG_SYMLINK      0xA000000C
+#define IO_REPARSE_TAG_MOUNT_POINT   0xA0000003
+#define IO_REPARSE_TAG_HSM           0xC0000004
+#define IO_REPARSE_TAG_SIS           0x80000007
+#define IO_REPARSE_TAG_DFS          0x8000000A
+#define IO_REPARSE_TAG_NFS          0x80000014
+
+/*
+ * Flag from [MS-FSCC] 2.1.2.4 Symbolic Link Reparse Data Buffer
+ */
+#define SYMLINK_FLAG_RELATIVE       0x00000001
+
 #endif /* _SMB_CONSTANTS_H */
diff --git a/source3/include/ntioctl.h b/source3/include/ntioctl.h
index 199a2476cb6..1c2e5d5eb07 100644
--- a/source3/include/ntioctl.h
+++ b/source3/include/ntioctl.h
@@ -20,15 +20,6 @@
 #ifndef _NTIOCTL_H
 #define _NTIOCTL_H
 
-#define IO_REPARSE_TAG_SYMLINK      0xA000000C
-#define SYMLINK_FLAG_RELATIVE       0x00000001
-
-#define IO_REPARSE_TAG_MOUNT_POINT   0xA0000003
-#define IO_REPARSE_TAG_HSM           0xC0000004
-#define IO_REPARSE_TAG_SIS           0x80000007
-#define IO_REPARSE_TAG_DFS          0x8000000A
-#define IO_REPARSE_TAG_NFS          0x80000014
-
 /* Sub-types for IO_REPARSE_TAG_NFS */
 #define NFS_SPECFILE_LNK            0x00000000014B4E4C
 #define NFS_SPECFILE_CHR            0x0000000000524843
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 90ec794a519..1513696f766 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -164,19 +164,6 @@
 #define ENCRYPTION_REQUIRED(conn) ((conn) ? ((conn)->encrypt_level == 
SMB_SIGNING_REQUIRED) : false)
 #define IS_CONN_ENCRYPTED(conn) ((conn) ? (conn)->encrypted_tid : false)
 
-/****************************************************************************
-true if two IPv4 addresses are equal
-****************************************************************************/
-
-#define ip_equal_v4(ip1,ip2) ((ip1).s_addr == (ip2).s_addr)
-
-/*****************************************************************
- splits out the last subkey of a key
- *****************************************************************/  
-
-#define reg_get_subkey(full_keyname, key_name, subkey_name) \
-       split_at_last_component(full_keyname, key_name, '\\', subkey_name)
-
 /****************************************************************************
  Return True if the offset is at zero.
 ****************************************************************************/
diff --git a/source3/libsmb/reparse_symlink.c b/source3/libsmb/reparse_symlink.c
index f981b5fcce7..b0b51814a55 100644
--- a/source3/libsmb/reparse_symlink.c
+++ b/source3/libsmb/reparse_symlink.c
@@ -53,7 +53,15 @@ bool symlink_reparse_buffer_marshall(
                                   &print_utf16, &print_len)) {
                goto fail;
        }
-       dst_len = 20 + subst_len + print_len;
+
+       dst_len = subst_len + 20;
+       if (dst_len < 20) {
+               goto fail;
+       }
+       dst_len += print_len;
+       if (dst_len < print_len) {
+               goto fail;
+       }
        dst = talloc_array(mem_ctx, uint8_t, dst_len);
        if (dst == NULL) {
                goto fail;
diff --git a/source3/modules/util_reparse.c b/source3/modules/util_reparse.c
new file mode 100644
index 00000000000..fe259b50646
--- /dev/null
+++ b/source3/modules/util_reparse.c
@@ -0,0 +1,50 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Utility functions for reparse points.
+ *
+ * Copyright (C) Jeremy Allison 2018
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "util_reparse.h"
+
+NTSTATUS fsctl_get_reparse_point(struct files_struct *fsp,
+                                TALLOC_CTX *ctx,
+                                char **out_data,
+                                uint32_t max_out_len,
+                                uint32_t *out_len)
+{
+       DBG_DEBUG("Called on %s\n", fsp_fnum_dbg(fsp));
+       return NT_STATUS_NOT_A_REPARSE_POINT;
+}
+
+NTSTATUS fsctl_set_reparse_point(struct files_struct *fsp,
+                                TALLOC_CTX *ctx,
+                                const uint8_t *in_data,
+                                uint32_t in_len)
+{
+       DBG_DEBUG("Called on %s\n", fsp_fnum_dbg(fsp));
+       return NT_STATUS_NOT_A_REPARSE_POINT;
+}
+
+NTSTATUS fsctl_del_reparse_point(struct files_struct *fsp,
+                                TALLOC_CTX *ctx,
+                                const uint8_t *in_data,
+                                uint32_t in_len)
+{
+       DBG_DEBUG("Called on %s\n", fsp_fnum_dbg(fsp));
+       return NT_STATUS_NOT_A_REPARSE_POINT;
+}
diff --git a/source3/rpc_server/epmapper/srv_epmapper.h 
b/source3/modules/util_reparse.h
similarity index 54%
copy from source3/rpc_server/epmapper/srv_epmapper.h
copy to source3/modules/util_reparse.h
index 7ec35ace666..102605edd19 100644
--- a/source3/rpc_server/epmapper/srv_epmapper.h
+++ b/source3/modules/util_reparse.h
@@ -1,9 +1,8 @@
 /*
  * Unix SMB/CIFS implementation.
+ * Utility functions for reparse points.
  *
- * Endpoint server for the epmapper pipe
- *
- * Copyright (C) 2010-2011 Andreas Schneider <[email protected]>
+ * Copyright (C) Jeremy Allison 2018
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,23 +18,23 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef _SRV_EPMAPPER_H_
-#define _SRV_EPMAPPER_H_
-
-struct dcesrv_connection;
+#ifndef __UTIL_REPARSE_H__
+#define __UTIL_REPARSE_H__
 
-/**
- * @brief Cleanup memory and other stuff.
- */
-void srv_epmapper_cleanup(void);
+NTSTATUS fsctl_get_reparse_point(struct files_struct *fsp,
+                                TALLOC_CTX *ctx,
+                                char **out_data,
+                                uint32_t max_out_len,
+                                uint32_t *out_len);
 
-/**
- * @brief Cleanup function used to delete endpoints when a ncalrpc connection
- *        from an external daemon is lost
- */
-void srv_epmapper_delete_endpoints(struct dcesrv_connection *conn,
-                                  void *private_data);
+NTSTATUS fsctl_set_reparse_point(struct files_struct *fsp,
+                                TALLOC_CTX *ctx,
+                                const uint8_t *in_data,
+                                uint32_t in_len);
 
-#endif /*_SRV_EPMAPPER_H_ */
+NTSTATUS fsctl_del_reparse_point(struct files_struct *fsp,
+                                TALLOC_CTX *ctx,
+                                const uint8_t *in_data,
+                                uint32_t in_len);
 
-/* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */
+#endif /* __UTIL_REPARSE_H__ */
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index fb9d16efd6b..cf5e1cbc296 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -35,6 +35,7 @@
 #include "lib/pthreadpool/pthreadpool_tevent.h"
 #include "librpc/gen_ndr/ndr_ioctl.h"
 #include "offload_token.h"
+#include "util_reparse.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -1367,18 +1368,21 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct 
*handle,
 
        case FSCTL_GET_REPARSE_POINT:
        {
-               /* Fail it with STATUS_NOT_A_REPARSE_POINT */
-               DEBUG(10, ("FSCTL_GET_REPARSE_POINT: called on %s. "
-                          "Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp)));
-               return NT_STATUS_NOT_A_REPARSE_POINT;
+               status = fsctl_get_reparse_point(
+                       fsp, ctx, out_data, max_out_len, out_len);
+               return status;
        }
 
        case FSCTL_SET_REPARSE_POINT:
        {
-               /* Fail it with STATUS_NOT_A_REPARSE_POINT */
-               DEBUG(10, ("FSCTL_SET_REPARSE_POINT: called on %s. "
-                          "Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp)));
-               return NT_STATUS_NOT_A_REPARSE_POINT;
+               status = fsctl_set_reparse_point(fsp, ctx, _in_data, in_len);
+               return status;
+       }
+
+       case FSCTL_DELETE_REPARSE_POINT:
+       {
+               status = fsctl_del_reparse_point(fsp, ctx, _in_data, in_len);
+               return status;
        }
 
        case FSCTL_GET_SHADOW_COPY_DATA:
diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
index 7f056f2b7f7..09528f38070 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -39,6 +39,10 @@ bld.SAMBA3_SUBSYSTEM('OFFLOAD_TOKEN',
                     source='offload_token.c',
                     deps='samba-util')
 
+bld.SAMBA3_SUBSYSTEM('UTIL_REPARSE',
+                    source='util_reparse.c',
+                    deps='samba-util')
+
 bld.SAMBA3_SUBSYSTEM('HASH_INODE',
                     source='hash_inode.c',
                     deps='gnutls')
@@ -50,7 +54,7 @@ bld.SAMBA3_SUBSYSTEM('HASH_INODE',
 bld.SAMBA3_MODULE('vfs_default',
                  subsystem='vfs',
                  source='vfs_default.c',
-                 deps='samba-util NDR_DFSBLOBS OFFLOAD_TOKEN',
+                 deps='samba-util NDR_DFSBLOBS OFFLOAD_TOKEN UTIL_REPARSE',
                  init_function='',
                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_default'),
                  enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_default'))
diff --git a/source3/nmbd/nmbd.h b/source3/nmbd/nmbd.h
index 47940e19401..551868e29ad 100644
--- a/source3/nmbd/nmbd.h
+++ b/source3/nmbd/nmbd.h
@@ -28,4 +28,10 @@
 #include "libsmb/nmblib.h"
 #include "nmbd/nmbd_proto.h"
 
+/****************************************************************************
+true if two IPv4 addresses are equal
+****************************************************************************/
+
+#define ip_equal_v4(ip1,ip2) ((ip1).s_addr == (ip2).s_addr)
+
 #endif /* _NMBD_NMBD_H_ */
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 72fae4048d3..73ea63ffd25 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -973,8 +973,9 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
        if (state->conn->printer) {
                /* we don't ever use the filenames on a printer share as a
                        filename - so don't convert them */
-               if (!(state->smb_fname->base_name = 
talloc_strdup(state->smb_fname,
-                                                          state->orig_path))) {
+               state->smb_fname->base_name = talloc_strdup(
+                       state->smb_fname, state->orig_path);
+               if (state->smb_fname->base_name == NULL) {
                        status = NT_STATUS_NO_MEMORY;
                        goto err;
                }
@@ -991,7 +992,9 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
        }
 
        /* Start with the full orig_path as given by the caller. */
-       if (!(state->smb_fname->base_name = talloc_strdup(state->smb_fname, 
state->orig_path))) {
+       state->smb_fname->base_name = talloc_strdup(
+               state->smb_fname, state->orig_path);
+       if (state->smb_fname->base_name == NULL) {
                DBG_ERR("talloc_strdup failed\n");
                status = NT_STATUS_NO_MEMORY;
                goto err;
@@ -1012,7 +1015,8 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
         */
 
        if (state->smb_fname->base_name[0] == '\0') {
-               if (!(state->smb_fname->base_name = 
talloc_strdup(state->smb_fname, "."))) {
+               state->smb_fname->base_name = talloc_strdup(state->smb_fname, 
".");
+               if (state->smb_fname->base_name == NULL) {
                        status = NT_STATUS_NO_MEMORY;
                        goto err;
                }
@@ -1111,7 +1115,7 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
         * If we're providing case insensitive semantics or
         * the underlying filesystem is case insensitive,
         * then a case-normalized hit in the stat-cache is
-        * authoratitive. JRA.
+        * authoritative. JRA.
         *
         * Note: We're only checking base_name.  The stream_name will be
         * added and verified in build_stream_path().
@@ -1139,10 +1143,13 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
         * building the directories with talloc_asprintf and free it.
         */
 
-       if ((state->dirpath == NULL) && (!(state->dirpath = 
talloc_strdup(state->mem_ctx,".")))) {
-               DBG_ERR("talloc_strdup failed\n");
-               status = NT_STATUS_NO_MEMORY;
-               goto err;
+       if (state->dirpath == NULL) {
+               state->dirpath = talloc_strdup(state->mem_ctx,".");
+               if (state->dirpath == NULL) {
+                       DBG_ERR("talloc_strdup failed\n");
+                       status = NT_STATUS_NO_MEMORY;
+                       goto err;
+               }
        }
 
        /*
@@ -1376,13 +1383,17 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
  fail:
        DBG_DEBUG("Conversion failed: dirpath [%s] name [%s]\n",
                  state->dirpath, state->name);
-       if (state->dirpath && !ISDOT(state->dirpath)) {
-               state->smb_fname->base_name = talloc_asprintf(state->smb_fname, 
"%s/%s",
-                                                      state->dirpath, 
state->name);
+       if ((state->dirpath != NULL) && !ISDOT(state->dirpath)) {
+               state->smb_fname->base_name = talloc_asprintf(
+                       state->smb_fname,
+                       "%s/%s",
+                       state->dirpath,
+                       state->name);
        } else {
-               state->smb_fname->base_name = talloc_strdup(state->smb_fname, 
state->name);
+               state->smb_fname->base_name = talloc_strdup(
+                       state->smb_fname, state->name);
        }
-       if (!state->smb_fname->base_name) {
+       if (state->smb_fname->base_name == NULL) {
                DBG_ERR("talloc_asprintf failed\n");
                status = NT_STATUS_NO_MEMORY;
                goto err;
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 85b23d35ba6..38b4070139d 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -1293,59 +1293,58 @@ NTSTATUS check_reduced_name(connection_struct *conn,
        resolved_fname = SMB_VFS_REALPATH(conn, ctx, smb_fname);
 
        if (resolved_fname == NULL) {
-               switch (errno) {
-                       case ENOTDIR:
-                               DEBUG(3,("check_reduced_name: Component not a "
-                                        "directory in getting realpath for "
-                                        "%s\n", fname));
-                               return NT_STATUS_OBJECT_PATH_NOT_FOUND;
-                       case ENOENT:
-                       {
-                               struct smb_filename *dir_fname = NULL;
-                               struct smb_filename *last_component = NULL;
-
-                               /* Last component didn't exist.
-                                  Remove it and try and canonicalise
-                                  the directory name. */
-
-                               ok = parent_smb_fname(ctx,
-                                                     smb_fname,
-                                                     &dir_fname,
-                                                     &last_component);
-                               if (!ok) {
-                                       return NT_STATUS_NO_MEMORY;
-                               }
+               struct smb_filename *dir_fname = NULL;
+               struct smb_filename *last_component = NULL;
+
+               if (errno == ENOTDIR) {
+                       DBG_NOTICE("Component not a directory in getting "
+                                  "realpath for %s\n",
+                                  fname);
+                       return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+               }
+               if (errno != ENOENT) {
+                       NTSTATUS status = map_nt_error_from_unix(errno);
+                       DBG_NOTICE("couldn't get realpath for %s: %s\n",
+                                  fname,
+                                  strerror(errno));
+                       return status;
+               }
 
-                               resolved_fname = SMB_VFS_REALPATH(conn,
-                                                       ctx,
-                                                       dir_fname);
-                               if (resolved_fname == NULL) {
-                                       NTSTATUS status = 
map_nt_error_from_unix(errno);


-- 
Samba Shared Repository

Reply via email to