Return correct error on name collision when creating new named
objects. Check for correct error in affected places.
This commit is contained in:
parent
2d41fcd864
commit
893987b871
|
@ -179,7 +179,7 @@ static void test_name_collisions(void)
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
UNICODE_STRING str;
|
UNICODE_STRING str;
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
HANDLE h, h1, h2;
|
HANDLE dir, h, h1, h2;
|
||||||
DWORD winerr;
|
DWORD winerr;
|
||||||
LARGE_INTEGER size;
|
LARGE_INTEGER size;
|
||||||
|
|
||||||
|
@ -204,12 +204,15 @@ static void test_name_collisions(void)
|
||||||
pRtlFreeUnicodeString(&str);
|
pRtlFreeUnicodeString(&str);
|
||||||
|
|
||||||
|
|
||||||
pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\om.c-test");
|
pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects");
|
||||||
|
DIR_TEST_OPEN_SUCCESS(&dir)
|
||||||
|
pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test");
|
||||||
|
InitializeObjectAttributes(&attr, &str, OBJ_OPENIF, dir, NULL);
|
||||||
|
|
||||||
h = CreateMutexA(NULL, FALSE, "om.c-test");
|
h = CreateMutexA(NULL, FALSE, "om.c-test");
|
||||||
ok(h != 0, "CreateMutexA failed got ret=%p (%ld)\n", h, GetLastError());
|
ok(h != 0, "CreateMutexA failed got ret=%p (%ld)\n", h, GetLastError());
|
||||||
status = pNtCreateMutant(&h1, GENERIC_ALL, &attr, FALSE);
|
status = pNtCreateMutant(&h1, GENERIC_ALL, &attr, FALSE);
|
||||||
todo_wine ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
||||||
"NtCreateMutant should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
"NtCreateMutant should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
||||||
h2 = CreateMutexA(NULL, FALSE, "om.c-test");
|
h2 = CreateMutexA(NULL, FALSE, "om.c-test");
|
||||||
winerr = GetLastError();
|
winerr = GetLastError();
|
||||||
|
@ -222,7 +225,7 @@ static void test_name_collisions(void)
|
||||||
h = CreateEventA(NULL, FALSE, FALSE, "om.c-test");
|
h = CreateEventA(NULL, FALSE, FALSE, "om.c-test");
|
||||||
ok(h != 0, "CreateEventA failed got ret=%p (%ld)\n", h, GetLastError());
|
ok(h != 0, "CreateEventA failed got ret=%p (%ld)\n", h, GetLastError());
|
||||||
status = pNtCreateEvent(&h1, GENERIC_ALL, &attr, FALSE, FALSE);
|
status = pNtCreateEvent(&h1, GENERIC_ALL, &attr, FALSE, FALSE);
|
||||||
todo_wine ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
||||||
"NtCreateEvent should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
"NtCreateEvent should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
||||||
h2 = CreateEventA(NULL, FALSE, FALSE, "om.c-test");
|
h2 = CreateEventA(NULL, FALSE, FALSE, "om.c-test");
|
||||||
winerr = GetLastError();
|
winerr = GetLastError();
|
||||||
|
@ -235,7 +238,7 @@ static void test_name_collisions(void)
|
||||||
h = CreateSemaphoreA(NULL, 1, 2, "om.c-test");
|
h = CreateSemaphoreA(NULL, 1, 2, "om.c-test");
|
||||||
ok(h != 0, "CreateSemaphoreA failed got ret=%p (%ld)\n", h, GetLastError());
|
ok(h != 0, "CreateSemaphoreA failed got ret=%p (%ld)\n", h, GetLastError());
|
||||||
status = pNtCreateSemaphore(&h1, GENERIC_ALL, &attr, 1, 2);
|
status = pNtCreateSemaphore(&h1, GENERIC_ALL, &attr, 1, 2);
|
||||||
todo_wine ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
||||||
"NtCreateSemaphore should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
"NtCreateSemaphore should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
||||||
h2 = CreateSemaphoreA(NULL, 1, 2, "om.c-test");
|
h2 = CreateSemaphoreA(NULL, 1, 2, "om.c-test");
|
||||||
winerr = GetLastError();
|
winerr = GetLastError();
|
||||||
|
@ -248,7 +251,7 @@ static void test_name_collisions(void)
|
||||||
h = CreateWaitableTimerA(NULL, TRUE, "om.c-test");
|
h = CreateWaitableTimerA(NULL, TRUE, "om.c-test");
|
||||||
ok(h != 0, "CreateWaitableTimerA failed got ret=%p (%ld)\n", h, GetLastError());
|
ok(h != 0, "CreateWaitableTimerA failed got ret=%p (%ld)\n", h, GetLastError());
|
||||||
status = pNtCreateTimer(&h1, GENERIC_ALL, &attr, NotificationTimer);
|
status = pNtCreateTimer(&h1, GENERIC_ALL, &attr, NotificationTimer);
|
||||||
todo_wine ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
||||||
"NtCreateTimer should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
"NtCreateTimer should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
||||||
h2 = CreateWaitableTimerA(NULL, TRUE, "om.c-test");
|
h2 = CreateWaitableTimerA(NULL, TRUE, "om.c-test");
|
||||||
winerr = GetLastError();
|
winerr = GetLastError();
|
||||||
|
@ -263,7 +266,7 @@ static void test_name_collisions(void)
|
||||||
size.u.LowPart = 256;
|
size.u.LowPart = 256;
|
||||||
size.u.HighPart = 0;
|
size.u.HighPart = 0;
|
||||||
status = pNtCreateSection(&h1, SECTION_MAP_WRITE, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0);
|
status = pNtCreateSection(&h1, SECTION_MAP_WRITE, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0);
|
||||||
todo_wine ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
ok(status == STATUS_OBJECT_NAME_EXISTS && h1 != NULL,
|
||||||
"NtCreateSection should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
"NtCreateSection should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
|
||||||
h2 = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 256, "om.c-test");
|
h2 = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 256, "om.c-test");
|
||||||
winerr = GetLastError();
|
winerr = GetLastError();
|
||||||
|
@ -274,6 +277,7 @@ static void test_name_collisions(void)
|
||||||
pNtClose(h2);
|
pNtClose(h2);
|
||||||
|
|
||||||
pRtlFreeUnicodeString(&str);
|
pRtlFreeUnicodeString(&str);
|
||||||
|
pNtClose(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_directory(void)
|
void test_directory(void)
|
||||||
|
|
|
@ -66,7 +66,7 @@ struct event *create_event( const struct unicode_str *name, unsigned int attr,
|
||||||
|
|
||||||
if ((event = create_named_object( sync_namespace, &event_ops, name, attr )))
|
if ((event = create_named_object( sync_namespace, &event_ops, name, attr )))
|
||||||
{
|
{
|
||||||
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
/* initialize it if it didn't already exist */
|
/* initialize it if it didn't already exist */
|
||||||
event->manual_reset = manual_reset;
|
event->manual_reset = manual_reset;
|
||||||
|
|
|
@ -230,7 +230,7 @@ static struct mailslot *create_mailslot( const struct unicode_str *name, unsigne
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* it already exists - there can only be one mailslot to read from */
|
/* it already exists - there can only be one mailslot to read from */
|
||||||
if (get_error() == STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() == STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
release_object( mailslot );
|
release_object( mailslot );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -280,7 +280,7 @@ static struct object *create_mapping( const struct unicode_str *name, unsigned i
|
||||||
|
|
||||||
if (!(mapping = create_named_object( sync_namespace, &mapping_ops, name, attr )))
|
if (!(mapping = create_named_object( sync_namespace, &mapping_ops, name, attr )))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (get_error() == STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() == STATUS_OBJECT_NAME_EXISTS)
|
||||||
return &mapping->obj; /* Nothing else to do */
|
return &mapping->obj; /* Nothing else to do */
|
||||||
|
|
||||||
mapping->header_size = 0;
|
mapping->header_size = 0;
|
||||||
|
|
|
@ -68,7 +68,7 @@ static struct mutex *create_mutex( const struct unicode_str *name, unsigned int
|
||||||
|
|
||||||
if ((mutex = create_named_object( sync_namespace, &mutex_ops, name, attr )))
|
if ((mutex = create_named_object( sync_namespace, &mutex_ops, name, attr )))
|
||||||
{
|
{
|
||||||
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
/* initialize it if it didn't already exist */
|
/* initialize it if it didn't already exist */
|
||||||
mutex->count = 0;
|
mutex->count = 0;
|
||||||
|
|
|
@ -444,10 +444,10 @@ static struct named_pipe *create_named_pipe( const struct unicode_str *name, uns
|
||||||
{
|
{
|
||||||
struct named_pipe *pipe;
|
struct named_pipe *pipe;
|
||||||
|
|
||||||
pipe = create_named_object( sync_namespace, &named_pipe_ops, name, attr );
|
pipe = create_named_object( sync_namespace, &named_pipe_ops, name, attr | OBJ_OPENIF );
|
||||||
if (pipe)
|
if (pipe)
|
||||||
{
|
{
|
||||||
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
/* initialize it if it didn't already exist */
|
/* initialize it if it didn't already exist */
|
||||||
pipe->instances = 0;
|
pipe->instances = 0;
|
||||||
|
@ -552,7 +552,7 @@ DECL_HANDLER(create_named_pipe)
|
||||||
get_req_unicode_str( &name );
|
get_req_unicode_str( &name );
|
||||||
if (!(pipe = create_named_pipe( &name, req->attributes ))) return;
|
if (!(pipe = create_named_pipe( &name, req->attributes ))) return;
|
||||||
|
|
||||||
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
pipe->insize = req->insize;
|
pipe->insize = req->insize;
|
||||||
pipe->outsize = req->outsize;
|
pipe->outsize = req->outsize;
|
||||||
|
|
|
@ -166,12 +166,17 @@ void *create_named_object( struct namespace *namespace, const struct object_ops
|
||||||
|
|
||||||
if ((obj = find_object( namespace, name, attributes )))
|
if ((obj = find_object( namespace, name, attributes )))
|
||||||
{
|
{
|
||||||
if (obj->ops != ops)
|
if (attributes & OBJ_OPENIF && obj->ops == ops)
|
||||||
|
set_error( STATUS_OBJECT_NAME_EXISTS );
|
||||||
|
else
|
||||||
{
|
{
|
||||||
release_object( obj );
|
release_object( obj );
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
|
if (attributes & OBJ_OPENIF)
|
||||||
|
set_error( STATUS_OBJECT_TYPE_MISMATCH );
|
||||||
|
else
|
||||||
|
set_error( STATUS_OBJECT_NAME_COLLISION );
|
||||||
}
|
}
|
||||||
set_error( STATUS_OBJECT_NAME_COLLISION );
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
if (!(name_ptr = alloc_name( name ))) return NULL;
|
if (!(name_ptr = alloc_name( name ))) return NULL;
|
||||||
|
|
|
@ -71,7 +71,7 @@ static struct semaphore *create_semaphore( const struct unicode_str *name, unsig
|
||||||
}
|
}
|
||||||
if ((sem = create_named_object( sync_namespace, &semaphore_ops, name, attr )))
|
if ((sem = create_named_object( sync_namespace, &semaphore_ops, name, attr )))
|
||||||
{
|
{
|
||||||
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
/* initialize it if it didn't already exist */
|
/* initialize it if it didn't already exist */
|
||||||
sem->count = initial;
|
sem->count = initial;
|
||||||
|
|
|
@ -75,7 +75,7 @@ static struct timer *create_timer( const struct unicode_str *name, unsigned int
|
||||||
|
|
||||||
if ((timer = create_named_object( sync_namespace, &timer_ops, name, attr )))
|
if ((timer = create_named_object( sync_namespace, &timer_ops, name, attr )))
|
||||||
{
|
{
|
||||||
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
/* initialize it if it didn't already exist */
|
/* initialize it if it didn't already exist */
|
||||||
timer->manual = manual;
|
timer->manual = manual;
|
||||||
|
|
|
@ -3763,6 +3763,7 @@ static const struct
|
||||||
{ "NO_SUCH_FILE", STATUS_NO_SUCH_FILE },
|
{ "NO_SUCH_FILE", STATUS_NO_SUCH_FILE },
|
||||||
{ "NO_TOKEN", STATUS_NO_TOKEN },
|
{ "NO_TOKEN", STATUS_NO_TOKEN },
|
||||||
{ "OBJECT_NAME_COLLISION", STATUS_OBJECT_NAME_COLLISION },
|
{ "OBJECT_NAME_COLLISION", STATUS_OBJECT_NAME_COLLISION },
|
||||||
|
{ "OBJECT_NAME_EXISTS", STATUS_OBJECT_NAME_EXISTS },
|
||||||
{ "OBJECT_NAME_INVALID", STATUS_OBJECT_NAME_INVALID },
|
{ "OBJECT_NAME_INVALID", STATUS_OBJECT_NAME_INVALID },
|
||||||
{ "OBJECT_NAME_NOT_FOUND", STATUS_OBJECT_NAME_NOT_FOUND },
|
{ "OBJECT_NAME_NOT_FOUND", STATUS_OBJECT_NAME_NOT_FOUND },
|
||||||
{ "OBJECT_PATH_INVALID", STATUS_OBJECT_PATH_INVALID },
|
{ "OBJECT_PATH_INVALID", STATUS_OBJECT_PATH_INVALID },
|
||||||
|
|
|
@ -96,7 +96,7 @@ static struct winstation *create_winstation( const struct unicode_str *name, uns
|
||||||
|
|
||||||
if ((winstation = create_named_object( winstation_namespace, &winstation_ops, name, attr )))
|
if ((winstation = create_named_object( winstation_namespace, &winstation_ops, name, attr )))
|
||||||
{
|
{
|
||||||
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
/* initialize it if it didn't already exist */
|
/* initialize it if it didn't already exist */
|
||||||
winstation->flags = flags;
|
winstation->flags = flags;
|
||||||
|
@ -186,7 +186,7 @@ static struct desktop *create_desktop( const struct unicode_str *name, unsigned
|
||||||
|
|
||||||
if ((desktop = create_named_object( winstation_namespace, &desktop_ops, &full_str, attr )))
|
if ((desktop = create_named_object( winstation_namespace, &desktop_ops, &full_str, attr )))
|
||||||
{
|
{
|
||||||
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
||||||
{
|
{
|
||||||
/* initialize it if it didn't already exist */
|
/* initialize it if it didn't already exist */
|
||||||
desktop->flags = flags;
|
desktop->flags = flags;
|
||||||
|
|
Loading…
Reference in New Issue