[ntdll] ObjectAttributes can be NULL (Coverity)

Paul Vriens Paul.Vriens at xs4all.nl
Mon Sep 18 06:21:31 CDT 2006


Hi,

when ObjectAttributes is NULL we bail out. Windows doesn't and returns a
handle. Added a simple test.

Should fix CID_55.

Changelog
  ObjectAttributes can be NULL.

Cheers,

Paul

---
 dlls/ntdll/om.c       |    2 +-
 dlls/ntdll/tests/om.c |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/dlls/ntdll/om.c b/dlls/ntdll/om.c
index 41855dc..c00aa41 100644
--- a/dlls/ntdll/om.c
+++ b/dlls/ntdll/om.c
@@ -551,7 +551,7 @@ NTSTATUS WINAPI NtCreateSymbolicLinkObje
         req->access = DesiredAccess;
         req->attributes = ObjectAttributes ? ObjectAttributes->Attributes : 0;
         req->rootdir = ObjectAttributes ? ObjectAttributes->RootDirectory : 0;
-        if (ObjectAttributes->ObjectName)
+        if (ObjectAttributes && ObjectAttributes->ObjectName)
         {
             req->name_len = ObjectAttributes->ObjectName->Length;
             wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index 2903984..8216b7c 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -479,6 +479,14 @@ void test_symboliclink(void)
     status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL, NULL);
     ok(status == STATUS_ACCESS_VIOLATION,
         "NtCreateSymbolicLinkObject should have failed with STATUS_ACCESS_VIOLATION got(%08lx)\n", status);
+
+    /* No attributes */
+    pRtlCreateUnicodeStringFromAsciiz(&target, "anywhere");
+    status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL, &target);
+    ok(status == STATUS_SUCCESS, "Failed to create SymbolicLink(%08lx)\n", status);
+    pNtClose(h);
+    pRtlFreeUnicodeString(&target);
+
     status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL);
     ok(status == STATUS_INVALID_PARAMETER,
         "NtOpenSymbolicLinkObject should have failed with STATUS_INVALID_PARAMETER got(%08lx)\n", status);
-- 
1.4.2.1




More information about the wine-patches mailing list