Alexandre Julliard : server: Align object attributes to a DWORD-boundary.
Alexandre Julliard
julliard at winehq.org
Thu Sep 20 13:45:33 CDT 2018
Module: wine
Branch: master
Commit: be40b01c37fdda79bead85eb21ad3e8de961c55a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=be40b01c37fdda79bead85eb21ad3e8de961c55a
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Sep 20 12:59:32 2018 +0200
server: Align object attributes to a DWORD-boundary.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/sync.c | 2 ++
include/wine/server_protocol.h | 2 +-
server/request.c | 9 ++++-----
server/trace.c | 3 +--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
index 8e406ce..bb462f2 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -114,6 +114,8 @@ NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_a
}
else if (attr->RootDirectory) return STATUS_OBJECT_NAME_INVALID;
+ len = (len + 3) & ~3; /* DWORD-align the entire structure */
+
*ret = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
if (!*ret) return STATUS_NO_MEMORY;
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 0b61b91..24eb95b 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -6535,6 +6535,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
-#define SERVER_PROTOCOL_VERSION 559
+#define SERVER_PROTOCOL_VERSION 560
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/request.c b/server/request.c
index 77f4f71..2dd84fb 100644
--- a/server/request.c
+++ b/server/request.c
@@ -214,16 +214,15 @@ const struct object_attributes *get_req_object_attributes( const struct security
/* 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;
+ data_size_t size = (sizeof(*attr) + (attr->sd_len & ~1) + (attr->name_len & ~1) + 3) & ~3;
- if (attr == &empty_attributes)
+ if (attr == &empty_attributes || size >= get_req_data_size())
{
*len = 0;
return NULL;
}
- ptr = (const WCHAR *)(attr + 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;
+ *len = get_req_data_size() - size;
+ return (const char *)get_req_data() + size;
}
/* write the remaining part of the reply */
diff --git a/server/trace.c b/server/trace.c
index 3c0d592..1a28cac 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -1119,8 +1119,7 @@ static void dump_varargs_object_attributes( const char *prefix, data_size_t size
fprintf( stderr, ",name=L\"" );
dump_strW( str, objattr->name_len / sizeof(WCHAR), stderr, "\"\"" );
fputc( '\"', stderr );
- remove_data( ((sizeof(*objattr) + objattr->sd_len) / sizeof(WCHAR)) * sizeof(WCHAR) +
- (objattr->name_len / sizeof(WCHAR)) * sizeof(WCHAR) );
+ remove_data( (sizeof(*objattr) + (objattr->sd_len & ~1) + (objattr->name_len & ~1) + 3) & ~3 );
}
fputc( '}', stderr );
}
More information about the wine-cvs
mailing list