diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index bbbcfbab171..36a9c86a00c 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -86,13 +86,7 @@ NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_a *ret = NULL; *ret_len = 0; - if (!attr) - { - *ret = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, len ); - if (!*ret) return STATUS_NO_MEMORY; - *ret_len = len; - return STATUS_SUCCESS; - } + if (!attr) return STATUS_SUCCESS; if ((sd = attr->SecurityDescriptor)) { diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 65f053654ed..8dd4994784f 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -6171,6 +6171,6 @@ union generic_reply struct terminate_job_reply terminate_job_reply; }; -#define SERVER_PROTOCOL_VERSION 493 +#define SERVER_PROTOCOL_VERSION 494 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/request.c b/server/request.c index 7b7d8b1b3fc..2debf6dbb72 100644 --- a/server/request.c +++ b/server/request.c @@ -169,9 +169,17 @@ void *set_reply_data_size( data_size_t size ) const struct object_attributes *get_req_object_attributes( const struct security_descriptor **sd, struct unicode_str *name ) { + static const struct object_attributes empty_attributes; const struct object_attributes *attr = get_req_data(); data_size_t size = get_req_data_size(); + if (!size) + { + *sd = NULL; + name->len = 0; + return &empty_attributes; + } + if ((size < sizeof(*attr)) || (size - sizeof(*attr) < attr->sd_len) || (size - sizeof(*attr) - attr->sd_len < attr->name_len)) { diff --git a/server/trace.c b/server/trace.c index e02b8c302a3..edfcaf52b9a 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1074,20 +1074,27 @@ static void dump_varargs_object_attributes( const char *prefix, data_size_t size const struct object_attributes *objattr = cur_data; fprintf( stderr,"%s{", prefix ); - if (size >= sizeof(struct object_attributes)) + if (size) { const WCHAR *str; - fprintf( stderr, "rootdir=%04x,attributes=%08x", objattr->rootdir, objattr->attributes ); - if (objattr->sd_len > size - sizeof(*objattr) || - objattr->name_len > size - sizeof(*objattr) - objattr->sd_len) + + if (size < sizeof(*objattr) || + (size - sizeof(*objattr) < objattr->sd_len) || + (size - sizeof(*objattr) - objattr->sd_len < objattr->name_len)) + { + fprintf( stderr, "***invalid***}" ); + remove_data( size ); return; + } + + fprintf( stderr, "rootdir=%04x,attributes=%08x", objattr->rootdir, objattr->attributes ); dump_inline_security_descriptor( ",sd=", (const struct security_descriptor *)(objattr + 1), objattr->sd_len ); str = (const WCHAR *)objattr + (sizeof(*objattr) + objattr->sd_len) / sizeof(WCHAR); 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 ); + (objattr->name_len / sizeof(WCHAR)) * sizeof(WCHAR) ); } fputc( '}', stderr ); } @@ -3928,10 +3935,7 @@ static void dump_get_directory_entry_reply( const struct get_directory_entry_rep static void dump_create_symlink_request( const struct create_symlink_request *req ) { fprintf( stderr, " access=%08x", req->access ); - fprintf( stderr, ", attributes=%08x", req->attributes ); - fprintf( stderr, ", rootdir=%04x", req->rootdir ); - fprintf( stderr, ", name_len=%u", req->name_len ); - dump_varargs_unicode_str( ", name=", min(cur_size,req->name_len) ); + dump_varargs_object_attributes( ", objattr=", cur_size ); dump_varargs_unicode_str( ", target_name=", cur_size ); }