Commit 14967933 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Fix another buffer overflow compiler warning.

parent d5468b9c
...@@ -1192,7 +1192,6 @@ DECL_HANDLER(map_view) ...@@ -1192,7 +1192,6 @@ DECL_HANDLER(map_view)
{ {
struct mapping *mapping = NULL; struct mapping *mapping = NULL;
struct memory_view *view; struct memory_view *view;
data_size_t namelen = 0;
if (!req->size || (req->base & page_mask) || req->base + req->size < req->base) /* overflow */ if (!req->size || (req->base & page_mask) || req->base + req->size < req->base) /* overflow */
{ {
...@@ -1211,6 +1210,8 @@ DECL_HANDLER(map_view) ...@@ -1211,6 +1210,8 @@ DECL_HANDLER(map_view)
if (!req->mapping) /* image mapping for a .so dll */ if (!req->mapping) /* image mapping for a .so dll */
{ {
data_size_t namelen = 0;
if (get_req_data_size() > sizeof(view->image)) namelen = get_req_data_size() - sizeof(view->image); if (get_req_data_size() > sizeof(view->image)) namelen = get_req_data_size() - sizeof(view->image);
if (!(view = mem_alloc( sizeof(struct memory_view) + namelen * sizeof(WCHAR) ))) return; if (!(view = mem_alloc( sizeof(struct memory_view) + namelen * sizeof(WCHAR) ))) return;
memset( view, 0, sizeof(*view) ); memset( view, 0, sizeof(*view) );
...@@ -1243,13 +1244,13 @@ DECL_HANDLER(map_view) ...@@ -1243,13 +1244,13 @@ DECL_HANDLER(map_view)
goto done; goto done;
} }
if ((view = mem_alloc( offsetof( struct memory_view, name[namelen] )))) if ((view = mem_alloc( sizeof(*view) )))
{ {
view->base = req->base; view->base = req->base;
view->size = req->size; view->size = req->size;
view->start = req->start; view->start = req->start;
view->flags = mapping->flags; view->flags = mapping->flags;
view->namelen = namelen; view->namelen = 0;
view->fd = !is_fd_removable( mapping->fd ) ? (struct fd *)grab_object( mapping->fd ) : NULL; view->fd = !is_fd_removable( mapping->fd ) ? (struct fd *)grab_object( mapping->fd ) : NULL;
view->committed = mapping->committed ? (struct ranges *)grab_object( mapping->committed ) : NULL; view->committed = mapping->committed ? (struct ranges *)grab_object( mapping->committed ) : NULL;
view->shared = mapping->shared ? (struct shared_map *)grab_object( mapping->shared ) : NULL; view->shared = mapping->shared ? (struct shared_map *)grab_object( mapping->shared ) : NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment