[PATCH 08/12] [Server]: properly return the errors for bare console objects
Eric Pouech
eric.pouech at orange.fr
Sat Aug 28 06:15:31 CDT 2010
A+
---
server/console.c | 59 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/server/console.c b/server/console.c
index ec44534..975613e 100644
--- a/server/console.c
+++ b/server/console.c
@@ -713,6 +713,13 @@ static int set_console_input_info( const struct set_console_input_info_request *
struct console_renderer_event evt;
if (!(console = console_input_get( req->handle, FILE_WRITE_PROPERTIES ))) goto error;
+ if (console_input_is_bare(console) &&
+ (req->mask & (SET_CONSOLE_INPUT_INFO_ACTIVE_SB|
+ SET_CONSOLE_INPUT_INFO_WIN)))
+ {
+ set_error( STATUS_UNSUCCESSFUL );
+ goto error;
+ }
memset(&evt.u, 0, sizeof(evt.u));
if (req->mask & SET_CONSOLE_INPUT_INFO_ACTIVE_SB)
@@ -1321,17 +1328,13 @@ static void read_console_output( struct screen_buffer *screen_buffer, int x, int
}
/* scroll parts of a screen buffer */
-static void scroll_console_output( obj_handle_t handle, int xsrc, int ysrc, int xdst, int ydst,
+static void scroll_console_output( struct screen_buffer *screen_buffer, int xsrc, int ysrc, int xdst, int ydst,
int w, int h )
{
- struct screen_buffer *screen_buffer;
int j;
char_info_t *psrc, *pdst;
struct console_renderer_event evt;
- if (!(screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, handle,
- FILE_WRITE_DATA, &screen_buffer_ops )))
- return;
if (xsrc < 0 || ysrc < 0 || xdst < 0 || ydst < 0 ||
xsrc + w > screen_buffer->width ||
xdst + w > screen_buffer->width ||
@@ -1340,7 +1343,6 @@ static void scroll_console_output( obj_handle_t handle, int xsrc, int ysrc, int
w == 0 || h == 0)
{
set_error( STATUS_INVALID_PARAMETER );
- release_object( screen_buffer );
return;
}
@@ -1378,8 +1380,6 @@ static void scroll_console_output( obj_handle_t handle, int xsrc, int ysrc, int
evt.u.update.top = min(ysrc, ydst);
evt.u.update.bottom = max(ysrc, ydst) + h - 1;
console_input_events_append( screen_buffer->input, &evt );
-
- release_object( screen_buffer );
}
/* allocate a console for the renderer */
@@ -1597,7 +1597,7 @@ DECL_HANDLER(create_console_output)
{
if ((fd = thread_get_inflight_fd( current, req->fd )) == -1)
{
- set_error( STATUS_INVALID_HANDLE ); /* FIXME */
+ set_error( STATUS_INVALID_HANDLE );
return;
}
}
@@ -1607,6 +1607,12 @@ DECL_HANDLER(create_console_output)
close(fd);
return;
}
+ if (console_input_is_bare( console ) ^ (fd != -1))
+ {
+ close( fd );
+ set_error( STATUS_INVALID_HANDLE );
+ return;
+ }
screen_buffer = create_console_output( console, fd );
if (screen_buffer)
@@ -1665,6 +1671,12 @@ DECL_HANDLER(read_console_output)
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
FILE_READ_DATA, &screen_buffer_ops )))
{
+ if (console_input_is_bare( screen_buffer->input ))
+ {
+ set_error( STATUS_OBJECT_TYPE_MISMATCH );
+ release_object( screen_buffer );
+ return;
+ }
read_console_output( screen_buffer, req->x, req->y, req->mode, req->wrap );
reply->width = screen_buffer->width;
reply->height = screen_buffer->height;
@@ -1680,6 +1692,12 @@ DECL_HANDLER(write_console_output)
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
FILE_WRITE_DATA, &screen_buffer_ops)))
{
+ if (console_input_is_bare( screen_buffer->input ))
+ {
+ set_error( STATUS_OBJECT_TYPE_MISMATCH );
+ release_object( screen_buffer );
+ return;
+ }
reply->written = write_console_output( screen_buffer, get_req_data_size(), get_req_data(),
req->mode, req->x, req->y, req->wrap );
reply->width = screen_buffer->width;
@@ -1696,6 +1714,12 @@ DECL_HANDLER(fill_console_output)
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
FILE_WRITE_DATA, &screen_buffer_ops)))
{
+ if (console_input_is_bare( screen_buffer->input ))
+ {
+ set_error( STATUS_OBJECT_TYPE_MISMATCH );
+ release_object( screen_buffer );
+ return;
+ }
reply->written = fill_console_output( screen_buffer, req->data, req->mode,
req->x, req->y, req->count, req->wrap );
release_object( screen_buffer );
@@ -1705,8 +1729,21 @@ DECL_HANDLER(fill_console_output)
/* move a rect of data in a screen buffer */
DECL_HANDLER(move_console_output)
{
- scroll_console_output( req->handle, req->x_src, req->y_src, req->x_dst, req->y_dst,
- req->w, req->h );
+ struct screen_buffer *screen_buffer;
+
+ if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
+ FILE_WRITE_DATA, &screen_buffer_ops)))
+ {
+ if (console_input_is_bare( screen_buffer->input ))
+ {
+ set_error( STATUS_OBJECT_TYPE_MISMATCH );
+ release_object( screen_buffer );
+ return;
+ }
+ scroll_console_output( screen_buffer, req->x_src, req->y_src, req->x_dst, req->y_dst,
+ req->w, req->h );
+ release_object( screen_buffer );
+ }
}
/* sends a signal to a console (process, group...) */
More information about the wine-patches
mailing list