Commit 7ad32cf5 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Allow lookup_name to distinguish the case of an empty path.

parent 9a08714c
...@@ -225,7 +225,6 @@ static void test_handles(void) ...@@ -225,7 +225,6 @@ static void test_handles(void)
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
w2 = CreateWindowStationA( "foo\\bar", 0, WINSTA_ALL_ACCESS, NULL ); w2 = CreateWindowStationA( "foo\\bar", 0, WINSTA_ALL_ACCESS, NULL );
ok( !w2, "create station succeeded\n" ); ok( !w2, "create station succeeded\n" );
todo_wine
ok( GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_ACCESS_DENIED, ok( GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_ACCESS_DENIED,
"wrong error %u\n", GetLastError() ); "wrong error %u\n", GetLastError() );
......
...@@ -144,6 +144,8 @@ static struct object *directory_lookup_name( struct object *obj, struct unicode_ ...@@ -144,6 +144,8 @@ static struct object *directory_lookup_name( struct object *obj, struct unicode_
assert( obj->ops == &directory_ops ); assert( obj->ops == &directory_ops );
if (!name) return NULL; /* open the directory itself */
if (!(p = memchrW( name->str, '\\', name->len / sizeof(WCHAR) ))) if (!(p = memchrW( name->str, '\\', name->len / sizeof(WCHAR) )))
/* Last element in the path name */ /* Last element in the path name */
tmp.len = name->len; tmp.len = name->len;
...@@ -165,14 +167,12 @@ static struct object *directory_lookup_name( struct object *obj, struct unicode_ ...@@ -165,14 +167,12 @@ static struct object *directory_lookup_name( struct object *obj, struct unicode_
return found; return found;
} }
if (name->str) if (name->str) /* not the last element */
{ {
if (tmp.len == 0) /* Double backslash */ if (tmp.len == 0) /* Double backslash */
set_error( STATUS_OBJECT_NAME_INVALID ); set_error( STATUS_OBJECT_NAME_INVALID );
else if (p) /* Path still has backslashes */ else if (p) /* Path still has backslashes */
set_error( STATUS_OBJECT_PATH_NOT_FOUND ); set_error( STATUS_OBJECT_PATH_NOT_FOUND );
else
clear_error();
} }
return NULL; return NULL;
} }
......
...@@ -370,6 +370,8 @@ static struct object *mailslot_device_lookup_name( struct object *obj, struct un ...@@ -370,6 +370,8 @@ static struct object *mailslot_device_lookup_name( struct object *obj, struct un
assert( obj->ops == &mailslot_device_ops ); assert( obj->ops == &mailslot_device_ops );
if (!name) return NULL; /* open the device itself */
if ((found = find_object( device->mailslots, name, attr | OBJ_CASE_INSENSITIVE ))) if ((found = find_object( device->mailslots, name, attr | OBJ_CASE_INSENSITIVE )))
name->len = 0; name->len = 0;
......
...@@ -473,6 +473,8 @@ static struct object *named_pipe_device_lookup_name( struct object *obj, struct ...@@ -473,6 +473,8 @@ static struct object *named_pipe_device_lookup_name( struct object *obj, struct
assert( obj->ops == &named_pipe_device_ops ); assert( obj->ops == &named_pipe_device_ops );
assert( device->pipes ); assert( device->pipes );
if (!name) return NULL; /* open the device itself */
if ((found = find_object( device->pipes, name, attr | OBJ_CASE_INSENSITIVE ))) if ((found = find_object( device->pipes, name, attr | OBJ_CASE_INSENSITIVE )))
name->len = 0; name->len = 0;
......
...@@ -217,7 +217,7 @@ struct object *lookup_named_object( struct object *root, const struct unicode_st ...@@ -217,7 +217,7 @@ struct object *lookup_named_object( struct object *root, const struct unicode_st
unsigned int attr, struct unicode_str *name_left ) unsigned int attr, struct unicode_str *name_left )
{ {
struct object *obj, *parent; struct object *obj, *parent;
struct unicode_str name_tmp = *name; struct unicode_str name_tmp = *name, *ptr = &name_tmp;
if (root) if (root)
{ {
...@@ -242,9 +242,11 @@ struct object *lookup_named_object( struct object *root, const struct unicode_st ...@@ -242,9 +242,11 @@ struct object *lookup_named_object( struct object *root, const struct unicode_st
parent = get_root_directory(); parent = get_root_directory();
} }
if (!name_tmp.len) goto done; if (!name_tmp.len) ptr = NULL; /* special case for empty path */
while ((obj = parent->ops->lookup_name( parent, &name_tmp, attr ))) clear_error();
while ((obj = parent->ops->lookup_name( parent, ptr, attr )))
{ {
/* move to the next element */ /* move to the next element */
release_object ( parent ); release_object ( parent );
...@@ -256,7 +258,6 @@ struct object *lookup_named_object( struct object *root, const struct unicode_st ...@@ -256,7 +258,6 @@ struct object *lookup_named_object( struct object *root, const struct unicode_st
return NULL; return NULL;
} }
done:
if (name_left) *name_left = name_tmp; if (name_left) *name_left = name_tmp;
return parent; return parent;
} }
...@@ -617,6 +618,7 @@ int default_set_sd( struct object *obj, const struct security_descriptor *sd, ...@@ -617,6 +618,7 @@ int default_set_sd( struct object *obj, const struct security_descriptor *sd,
struct object *no_lookup_name( struct object *obj, struct unicode_str *name, struct object *no_lookup_name( struct object *obj, struct unicode_str *name,
unsigned int attr ) unsigned int attr )
{ {
if (!name) set_error( STATUS_OBJECT_TYPE_MISMATCH );
return NULL; return NULL;
} }
......
...@@ -99,11 +99,13 @@ static struct object *symlink_lookup_name( struct object *obj, struct unicode_st ...@@ -99,11 +99,13 @@ static struct object *symlink_lookup_name( struct object *obj, struct unicode_st
struct object *target; struct object *target;
assert( obj->ops == &symlink_ops ); assert( obj->ops == &symlink_ops );
if (!name) return NULL;
if (!name->len && (attr & OBJ_OPENLINK)) return NULL; if (!name->len && (attr & OBJ_OPENLINK)) return NULL;
target_str.str = symlink->target; target_str.str = symlink->target;
target_str.len = symlink->len; target_str.len = symlink->len;
if ((target = find_object_dir( NULL, &target_str, attr, &name_left ))) if ((target = lookup_named_object( NULL, &target_str, attr, &name_left )))
{ {
if (name_left.len) if (name_left.len)
{ {
......
...@@ -110,12 +110,6 @@ static struct winstation *create_winstation( struct directory *root, const struc ...@@ -110,12 +110,6 @@ static struct winstation *create_winstation( struct directory *root, const struc
{ {
struct winstation *winstation; struct winstation *winstation;
if (memchrW( name->str, '\\', name->len / sizeof(WCHAR) )) /* no backslash allowed in name */
{
set_error( STATUS_INVALID_PARAMETER );
return NULL;
}
if ((winstation = create_named_object_dir( root, name, attr, &winstation_ops ))) if ((winstation = create_named_object_dir( root, name, attr, &winstation_ops )))
{ {
if (get_error() != STATUS_OBJECT_NAME_EXISTS) if (get_error() != STATUS_OBJECT_NAME_EXISTS)
...@@ -165,6 +159,8 @@ static struct object *winstation_lookup_name( struct object *obj, struct unicode ...@@ -165,6 +159,8 @@ static struct object *winstation_lookup_name( struct object *obj, struct unicode
assert( obj->ops == &winstation_ops ); assert( obj->ops == &winstation_ops );
if (!name) return NULL; /* open the winstation itself */
if (memchrW( name->str, '\\', name->len / sizeof(WCHAR) )) /* no backslash allowed in name */ if (memchrW( name->str, '\\', name->len / sizeof(WCHAR) )) /* no backslash allowed in name */
{ {
set_error( STATUS_OBJECT_PATH_SYNTAX_BAD ); set_error( STATUS_OBJECT_PATH_SYNTAX_BAD );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment