[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed Sep 12 00:06:02 UTC 2018


The branch, master has been updated
       via  0993141 smbd:vfs: fix mis-spellings of hierarchy in comments
       via  ba9d293 s3: smbd: Ensure dirpath is set to ".", not "
       via  de75410 s3: smbd: Restructure check_parent_exists() to ensure all non-optimization returns go to one place.
       via  204e054 s3: smbd: Initialization cleanup.
      from  885435e s3:libsmbclient: Fix a typo

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


- Log -----------------------------------------------------------------
commit 0993141c55ad788c5f9de3b96a6ddeca6bfbc453
Author: Michael Adam <obnox at samba.org>
Date:   Mon Aug 20 12:04:20 2018 +0200

    smbd:vfs: fix mis-spellings of hierarchy in comments
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Sep 12 02:05:47 CEST 2018 on sn-devel-144

commit ba9d293ccf524b12c4f03cdb6a6acab3e46bc696
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 22 13:37:04 2018 -0700

    s3: smbd: Ensure dirpath is set to ".", not "\0" so it is always a valid path.
    
    Cleanup of the internals of unix_convert().
    
    Ensure check_parent_exists() returns this in the non-optimization
    case. Ensure unix_convert() initializes dirpath to ".".
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit de7541059360b597c3d2ea383b0eb2fc2f7018d5
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 22 09:15:12 2018 -0700

    s3: smbd: Restructure check_parent_exists() to ensure all non-optimization returns go to one place.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 204e054b3ba9c452fb99a97bb5788ca10e2ce5a8
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 22 09:09:27 2018 -0700

    s3: smbd: Initialization cleanup.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

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

Summary of changes:
 source3/smbd/filename.c | 54 +++++++++++++++++++++++++++++++++----------------
 source3/smbd/vfs.c      |  6 +++---
 2 files changed, 40 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 41c1710..16d0f34 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -164,13 +164,11 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
 				char **pp_dirpath,
 				char **pp_start)
 {
-	struct smb_filename parent_fname;
+	struct smb_filename parent_fname = {0};
 	const char *last_component = NULL;
 	NTSTATUS status;
 	int ret;
-	bool parent_fname_has_wild = false;
 
-	ZERO_STRUCT(parent_fname);
 	if (!parent_dirname(ctx, smb_fname->base_name,
 				&parent_fname.base_name,
 				&last_component)) {
@@ -178,18 +176,18 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
 	}
 
 	if (!posix_pathnames) {
-		parent_fname_has_wild = ms_has_wild(parent_fname.base_name);
+		if (ms_has_wild(parent_fname.base_name)) {
+			goto no_optimization_out;
+		}
 	}
 
 	/*
 	 * If there was no parent component in
-	 * smb_fname->base_name of the parent name
-	 * contained a wildcard then don't do this
+	 * smb_fname->base_name then don't do this
 	 * optimization.
 	 */
-	if ((smb_fname->base_name == last_component) ||
-			parent_fname_has_wild) {
-		return NT_STATUS_OK;
+	if (smb_fname->base_name == last_component) {
+		goto no_optimization_out;
 	}
 
 	if (posix_pathnames) {
@@ -202,7 +200,7 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
 	   with the normal tree walk. */
 
 	if (ret == -1) {
-		return NT_STATUS_OK;
+		goto no_optimization_out;
 	}
 
 	status = check_for_dot_component(&parent_fname);
@@ -235,6 +233,28 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
 		*pp_start));
 
 	return NT_STATUS_OK;
+
+  no_optimization_out:
+
+	/*
+	 * We must still return an *pp_dirpath
+	 * initialized to ".", and a *pp_start
+	 * pointing at smb_fname->base_name.
+	 */
+
+	TALLOC_FREE(parent_fname.base_name);
+
+	*pp_dirpath = talloc_strdup(ctx, ".");
+	if (*pp_dirpath == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+	/*
+	 * Safe to use discard_const_p
+	 * here as by convention smb_fname->base_name
+	 * is allocated off ctx.
+	 */
+	*pp_start = discard_const_p(char, smb_fname->base_name);
+	return NT_STATUS_OK;
 }
 
 /*
@@ -599,7 +619,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 					goto err;
 				}
 				/* dirpath must exist. */
-				dirpath = talloc_strdup(ctx,"");
+				dirpath = talloc_strdup(ctx,".");
 				if (dirpath == NULL) {
 					status = NT_STATUS_NO_MEMORY;
 					goto err;
@@ -636,7 +656,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 	 * building the directories with talloc_asprintf and free it.
 	 */
 
-	if ((dirpath == NULL) && (!(dirpath = talloc_strdup(ctx,"")))) {
+	if ((dirpath == NULL) && (!(dirpath = talloc_strdup(ctx,".")))) {
 		DEBUG(0, ("talloc_strdup failed\n"));
 		status = NT_STATUS_NO_MEMORY;
 		goto err;
@@ -1036,7 +1056,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 					size_t start_ofs =
 					    start - smb_fname->base_name;
 
-					if (*dirpath != '\0') {
+					if (!ISDOT(dirpath)) {
 						tmp = talloc_asprintf(
 							smb_fname, "%s/%s",
 							dirpath, unmangled);
@@ -1071,7 +1091,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 				size_t start_ofs =
 				    start - smb_fname->base_name;
 
-				if (*dirpath != '\0') {
+				if (!ISDOT(dirpath)) {
 					tmp = talloc_asprintf(smb_fname,
 						"%s/%s/%s", dirpath,
 						found_name, end+1);
@@ -1096,7 +1116,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 				size_t start_ofs =
 				    start - smb_fname->base_name;
 
-				if (*dirpath != '\0') {
+				if (!ISDOT(dirpath)) {
 					tmp = talloc_asprintf(smb_fname,
 						"%s/%s", dirpath,
 						found_name);
@@ -1137,7 +1157,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 		 * Add to the dirpath that we have resolved so far.
 		 */
 
-		if (*dirpath != '\0') {
+		if (!ISDOT(dirpath)) {
 			char *tmp = talloc_asprintf(ctx,
 					"%s/%s", dirpath, start);
 			if (!tmp) {
@@ -1207,7 +1227,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 	return NT_STATUS_OK;
  fail:
 	DEBUG(10, ("dirpath = [%s] start = [%s]\n", dirpath, start));
-	if (dirpath && *dirpath != '\0') {
+	if (dirpath && !ISDOT(dirpath)) {
 		smb_fname->base_name = talloc_asprintf(smb_fname, "%s/%s",
 						       dirpath, start);
 	} else {
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index a6c49cf..28ebfc9 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -983,7 +983,7 @@ struct smb_filename *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
 
 /*******************************************************************
  Reduce a file name, removing .. elements and checking that
- it is below dir in the heirachy. This uses realpath.
+ it is below dir in the hierarchy. This uses realpath.
  This function must run as root, and will return names
  and valid stat structs that can be checked on open.
 ********************************************************************/
@@ -1172,7 +1172,7 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
 
 /*******************************************************************
  Reduce a file name, removing .. elements and checking that
- it is below dir in the heirachy. This uses realpath.
+ it is below dir in the hierarchy. This uses realpath.
 
  If cwd_name == NULL then fname is a client given path relative
  to the root path of the share.
@@ -2198,7 +2198,7 @@ struct smb_vfs_ev_glue *smb_vfs_ev_glue_create(TALLOC_CTX *mem_ctx,
 	}
 
 	/*
-	 * We now setup the glue hierachie.
+	 * We now setup the glue hierarchy.
 	 *
 	 * Search for "Design of the smb_vfs_ev_glue infrastructure" above
 	 * for a detailed description how the chain works.


-- 
Samba Shared Repository



More information about the samba-cvs mailing list