summaryrefslogtreecommitdiff
path: root/source3/smbd/filename.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-01-13 01:29:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:06 -0500
commitdd5e9e2ae7ba3c4f3d4d8e02c7a993dd8e164c5b (patch)
tree987f4a05464f0af0c341676a0117afcea77d65fa /source3/smbd/filename.c
parent1a40a6e08a58d02e912aaa9f81dcff48477f3b81 (diff)
downloadsamba-dd5e9e2ae7ba3c4f3d4d8e02c7a993dd8e164c5b.tar.gz
samba-dd5e9e2ae7ba3c4f3d4d8e02c7a993dd8e164c5b.tar.bz2
samba-dd5e9e2ae7ba3c4f3d4d8e02c7a993dd8e164c5b.zip
r20721: Fix the search unix_convert error returns. Only open
to go... Jeremy. (This used to be commit 89f03a8db40365f99c6755ff19a4bfbf8d1bd316)
Diffstat (limited to 'source3/smbd/filename.c')
-rw-r--r--source3/smbd/filename.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 44916200da..dd1e0de20f 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -57,6 +57,38 @@ static BOOL mangled_equal(const char *name1, const char *name2,
}
/****************************************************************************
+ Cope with the differing wildcard and non-wildcard error cases.
+****************************************************************************/
+
+static NTSTATUS determine_path_error(const char *name, BOOL allow_wcard_last_component)
+{
+ const char *p;
+
+ if (!allow_wcard_last_component) {
+ /* Error code within a pathname. */
+ return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+ }
+
+ /* We're terminating here so we
+ * can be a little slower and get
+ * the error code right. Windows
+ * treats the last part of the pathname
+ * separately I think, so if the last
+ * component is a wildcard then we treat
+ * this ./ as "end of component" */
+
+ p = strchr(name, '/');
+
+ if (!p && (ms_has_wild(name) || ISDOT(name))) {
+ /* Error code at the end of a pathname. */
+ return NT_STATUS_OBJECT_NAME_INVALID;
+ } else {
+ /* Error code within a pathname. */
+ return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+ }
+}
+
+/****************************************************************************
This routine is called to convert names from the dos namespace to unix
namespace. It needs to handle any case conversions, mangling, format
changes etc.
@@ -150,8 +182,7 @@ NTSTATUS unix_convert(connection_struct *conn,
if (name[1] == '\0' || name[2] == '\0') {
return NT_STATUS_OBJECT_NAME_INVALID;
} else {
- /* Longer pathname starts with ./ */
- return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+ return determine_path_error(&name[2], allow_wcard_last_component);
}
}
@@ -264,32 +295,11 @@ NTSTATUS unix_convert(connection_struct *conn,
/* The name cannot have a component of "." */
if (ISDOT(start)) {
- if (end) {
- if (allow_wcard_last_component) {
- /* We're terminating here so we
- * can be a little slower and get
- * the error code right. Windows
- * treats the last part of the pathname
- * separately I think, so if the last
- * component is a wildcard then we treat
- * this ./ as "end of component" */
-
- const char *p = strchr(end+1, '/');
-
- if (!p && ms_has_wild(end+1)) {
- /* Error code at the end of a pathname. */
- return NT_STATUS_OBJECT_NAME_INVALID;
- } else {
- /* Error code within a pathname. */
- return NT_STATUS_OBJECT_PATH_NOT_FOUND;
- }
- }
- /* Error code within a pathname. */
- return NT_STATUS_OBJECT_PATH_NOT_FOUND;
- } else {
+ if (!end) {
/* Error code at the end of a pathname. */
return NT_STATUS_OBJECT_NAME_INVALID;
}
+ return determine_path_error(end+1, allow_wcard_last_component);
}
/* The name cannot have a wildcard if it's not