From: Volker Lendecke Date: Fri, 12 Jun 2020 09:36:56 +0000 (+0200) Subject: smbd: Reduce indentation in check_reduced_name() X-Git-Tag: ldb-2.2.0~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1943e967a06ee83c7fed36280f8577f6245fb266;p=thirdparty%2Fsamba.git smbd: Reduce indentation in check_reduced_name() No change in behaviour. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- 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); - - if (errno == ENOENT || errno == ENOTDIR) { - status = NT_STATUS_OBJECT_PATH_NOT_FOUND; - } - - DEBUG(3,("check_reduce_name: " - "couldn't get realpath for " - "%s (%s)\n", - smb_fname_str_dbg(dir_fname), - nt_errstr(status))); - return status; - } - resolved_name = talloc_asprintf(ctx, + /* errno == ENOENT */ + + /* + * 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; + } + + resolved_fname = SMB_VFS_REALPATH(conn, ctx, dir_fname); + if (resolved_fname == NULL) { + NTSTATUS status = map_nt_error_from_unix(errno); + + if (errno == ENOENT || errno == ENOTDIR) { + status = NT_STATUS_OBJECT_PATH_NOT_FOUND; + } + + DBG_NOTICE("couldn't get realpath for " + "%s (%s)\n", + smb_fname_str_dbg(dir_fname), + nt_errstr(status)); + return status; + } + resolved_name = talloc_asprintf(ctx, "%s/%s", resolved_fname->base_name, last_component->base_name); - if (resolved_name == NULL) { - return NT_STATUS_NO_MEMORY; - } - break; - } - default: - DEBUG(3,("check_reduced_name: couldn't get " - "realpath for %s\n", fname)); - return map_nt_error_from_unix(errno); + if (resolved_name == NULL) { + return NT_STATUS_NO_MEMORY; } } else { resolved_name = resolved_fname->base_name;