Alexandre Julliard : server: Add a helper function to skip the object attributes structure.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jan 19 10:50:28 CST 2016


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jan 19 15:00:21 2016 +0900

server: Add a helper function to skip the object attributes structure.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 server/file.c    | 3 +--
 server/request.c | 9 +++++++++
 server/request.h | 1 +
 server/symlink.c | 5 ++---
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/server/file.c b/server/file.c
index 9fd3a9e..39f6ff0 100644
--- a/server/file.c
+++ b/server/file.c
@@ -711,8 +711,7 @@ DECL_HANDLER(create_file)
         if (!root_fd) return;
     }
 
-    name = (const char *)get_req_data() + sizeof(*objattr) + objattr->sd_len;
-    name_len = get_req_data_size() - sizeof(*objattr) - objattr->sd_len;
+    name = get_req_data_after_objattr( objattr, &name_len );
 
     reply->handle = 0;
     if ((file = create_file( root_fd, name, name_len, req->access, req->sharing,
diff --git a/server/request.c b/server/request.c
index 2debf6d..942bc42 100644
--- a/server/request.c
+++ b/server/request.c
@@ -198,6 +198,15 @@ const struct object_attributes *get_req_object_attributes( const struct security
     return attr;
 }
 
+/* return a pointer to the request data following an object attributes structure */
+const void *get_req_data_after_objattr( const struct object_attributes *attr, data_size_t *len )
+{
+    const void *ptr = (const WCHAR *)((const struct object_attributes *)get_req_data() + 1) +
+                       attr->sd_len / sizeof(WCHAR) + attr->name_len / sizeof(WCHAR);
+    *len = get_req_data_size() - ((const char *)ptr - (const char *)get_req_data());
+    return ptr;
+}
+
 /* write the remaining part of the reply */
 void write_reply( struct thread *thread )
 {
diff --git a/server/request.h b/server/request.h
index 2c99c79..caaa30e 100644
--- a/server/request.h
+++ b/server/request.h
@@ -48,6 +48,7 @@ extern const char *get_config_dir(void);
 extern void *set_reply_data_size( data_size_t size );
 extern const struct object_attributes *get_req_object_attributes( const struct security_descriptor **sd,
                                                                   struct unicode_str *name );
+extern const void *get_req_data_after_objattr( const struct object_attributes *attr, data_size_t *len );
 extern int receive_fd( struct process *process );
 extern int send_client_fd( struct process *process, int fd, obj_handle_t handle );
 extern void read_request( struct thread *thread );
diff --git a/server/symlink.c b/server/symlink.c
index 28d51ab..abc34f2 100644
--- a/server/symlink.c
+++ b/server/symlink.c
@@ -174,9 +174,8 @@ DECL_HANDLER(create_symlink)
 
     if (!objattr) return;
 
-    target.str = (const WCHAR *)get_req_data() + sizeof(*objattr) / sizeof(WCHAR) +
-                  objattr->sd_len / sizeof(WCHAR) + name.len / sizeof(WCHAR);
-    target.len = get_req_data_size() - ((const char *)target.str - (const char *)get_req_data());
+    target.str = get_req_data_after_objattr( objattr, &target.len );
+    target.len = (target.len / sizeof(WCHAR)) * sizeof(WCHAR);
 
     if (objattr->rootdir && !(root = get_directory_obj( current->process, objattr->rootdir, 0 ))) return;
 




More information about the wine-cvs mailing list