Alexandre Julliard : ntdll: Append a terminating null and return the correct length in NtQuerySymbolicLinkObject .

Alexandre Julliard julliard at winehq.org
Wed Jun 30 11:13:43 CDT 2010


Module: wine
Branch: master
Commit: 6df7e7b94362f874a5b5a46cda0eead8f517c651
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6df7e7b94362f874a5b5a46cda0eead8f517c651

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jun 30 16:11:42 2010 +0200

ntdll: Append a terminating null and return the correct length in NtQuerySymbolicLinkObject.

---

 dlls/ntdll/om.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/dlls/ntdll/om.c b/dlls/ntdll/om.c
index c5d9b84..0e64ddd 100644
--- a/dlls/ntdll/om.c
+++ b/dlls/ntdll/om.c
@@ -634,33 +634,36 @@ NTSTATUS WINAPI NtCreateSymbolicLinkObject(OUT PHANDLE SymbolicLinkHandle,IN ACC
  *  ZwQuerySymbolicLinkObject	[NTDLL.@]
  *
  * Query a namespace symbolic link object target name.
- * 
+ *
  * PARAMS
- *  LinkHandle     [I] Handle to a symbolic link object
- *  LinkTarget     [O] Destination for the symbolic link target
- *  ReturnedLength [O] Size of returned data
+ *  handle     [I] Handle to a symbolic link object
+ *  target     [O] Destination for the symbolic link target
+ *  length     [O] Size of returned data
  *
  * RETURNS
  *  Success: ERROR_SUCCESS.
  *  Failure: An NTSTATUS error code.
  */
-NTSTATUS WINAPI NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, IN OUT PUNICODE_STRING LinkTarget,
-                                          OUT PULONG ReturnedLength OPTIONAL)
+NTSTATUS WINAPI NtQuerySymbolicLinkObject( HANDLE handle, PUNICODE_STRING target, PULONG length )
 {
     NTSTATUS ret;
-    TRACE("(%p,%p,%p)\n", LinkHandle, LinkTarget, ReturnedLength);
 
-    if (!LinkTarget) return STATUS_ACCESS_VIOLATION;
+    TRACE("(%p,%p,%p)\n", handle, target, length );
+
+    if (!target) return STATUS_ACCESS_VIOLATION;
 
     SERVER_START_REQ(query_symlink)
     {
-        req->handle = wine_server_obj_handle( LinkHandle );
-        wine_server_set_reply( req, LinkTarget->Buffer, LinkTarget->MaximumLength );
+        req->handle = wine_server_obj_handle( handle );
+        if (target->MaximumLength >= sizeof(WCHAR))
+            wine_server_set_reply( req, target->Buffer, target->MaximumLength - sizeof(WCHAR) );
         if (!(ret = wine_server_call( req )))
         {
-            LinkTarget->Length = wine_server_reply_size(reply);
-            if (ReturnedLength) *ReturnedLength = LinkTarget->Length;
+            target->Length = wine_server_reply_size(reply);
+            target->Buffer[target->Length / sizeof(WCHAR)] = 0;
+            if (length) *length = reply->total + sizeof(WCHAR);
         }
+        else if (length && ret == STATUS_BUFFER_TOO_SMALL) *length = reply->total + sizeof(WCHAR);
     }
     SERVER_END_REQ;
     return ret;




More information about the wine-cvs mailing list