libfreerdp-core: change fastpath return codes

This commit is contained in:
Marc-André Moreau 2013-01-16 18:01:10 -05:00
parent 0146b21eb5
commit df01ba88d4
3 changed files with 53 additions and 34 deletions

View File

@ -198,8 +198,9 @@ static BOOL fastpath_recv_update_synchronize(rdpFastPath* fastpath, STREAM* s)
return TRUE; return TRUE;
} }
static BOOL fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32 size, STREAM* s) static int fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32 size, STREAM* s)
{ {
int status = 0;
rdpUpdate* update = fastpath->rdp->update; rdpUpdate* update = fastpath->rdp->update;
rdpContext* context = fastpath->rdp->update->context; rdpContext* context = fastpath->rdp->update->context;
rdpPointerUpdate* pointer = update->pointer; rdpPointerUpdate* pointer = update->pointer;
@ -213,13 +214,13 @@ static BOOL fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32
{ {
case FASTPATH_UPDATETYPE_ORDERS: case FASTPATH_UPDATETYPE_ORDERS:
if (!fastpath_recv_orders(fastpath, s)) if (!fastpath_recv_orders(fastpath, s))
return FALSE; return -1;
break; break;
case FASTPATH_UPDATETYPE_BITMAP: case FASTPATH_UPDATETYPE_BITMAP:
case FASTPATH_UPDATETYPE_PALETTE: case FASTPATH_UPDATETYPE_PALETTE:
if (!fastpath_recv_update_common(fastpath, s)) if (!fastpath_recv_update_common(fastpath, s))
return FALSE; return -1;
break; break;
case FASTPATH_UPDATETYPE_SYNCHRONIZE: case FASTPATH_UPDATETYPE_SYNCHRONIZE:
@ -230,8 +231,7 @@ static BOOL fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32
break; break;
case FASTPATH_UPDATETYPE_SURFCMDS: case FASTPATH_UPDATETYPE_SURFCMDS:
if (update_recv_surfcmds(update, size, s) < 0) status = update_recv_surfcmds(update, size, s);
return FALSE;
break; break;
case FASTPATH_UPDATETYPE_PTR_NULL: case FASTPATH_UPDATETYPE_PTR_NULL:
@ -246,25 +246,25 @@ static BOOL fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32
case FASTPATH_UPDATETYPE_PTR_POSITION: case FASTPATH_UPDATETYPE_PTR_POSITION:
if (!update_read_pointer_position(s, &pointer->pointer_position)) if (!update_read_pointer_position(s, &pointer->pointer_position))
return FALSE; return -1;
IFCALL(pointer->PointerPosition, context, &pointer->pointer_position); IFCALL(pointer->PointerPosition, context, &pointer->pointer_position);
break; break;
case FASTPATH_UPDATETYPE_COLOR: case FASTPATH_UPDATETYPE_COLOR:
if (!update_read_pointer_color(s, &pointer->pointer_color)) if (!update_read_pointer_color(s, &pointer->pointer_color))
return FALSE; return -1;
IFCALL(pointer->PointerColor, context, &pointer->pointer_color); IFCALL(pointer->PointerColor, context, &pointer->pointer_color);
break; break;
case FASTPATH_UPDATETYPE_CACHED: case FASTPATH_UPDATETYPE_CACHED:
if (!update_read_pointer_cached(s, &pointer->pointer_cached)) if (!update_read_pointer_cached(s, &pointer->pointer_cached))
return FALSE; return -1;
IFCALL(pointer->PointerCached, context, &pointer->pointer_cached); IFCALL(pointer->PointerCached, context, &pointer->pointer_cached);
break; break;
case FASTPATH_UPDATETYPE_POINTER: case FASTPATH_UPDATETYPE_POINTER:
if (!update_read_pointer_new(s, &pointer->pointer_new)) if (!update_read_pointer_new(s, &pointer->pointer_new))
return FALSE; return -1;
IFCALL(pointer->PointerNew, context, &pointer->pointer_new); IFCALL(pointer->PointerNew, context, &pointer->pointer_new);
break; break;
@ -273,11 +273,12 @@ static BOOL fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32
break; break;
} }
return TRUE; return status;
} }
static BOOL fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s) static BOOL fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
{ {
int status;
UINT16 size; UINT16 size;
int next_pos; int next_pos;
UINT32 totalSize; UINT32 totalSize;
@ -291,6 +292,7 @@ static BOOL fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
UINT32 roff; UINT32 roff;
UINT32 rlen; UINT32 rlen;
status = 0;
rdp = fastpath->rdp; rdp = fastpath->rdp;
fastpath_read_update_header(s, &updateCode, &fragmentation, &compression); fastpath_read_update_header(s, &updateCode, &fragmentation, &compression);
@ -301,8 +303,10 @@ static BOOL fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
compressionFlags = 0; compressionFlags = 0;
stream_read_UINT16(s, size); stream_read_UINT16(s, size);
if (stream_get_left(s) < size) if (stream_get_left(s) < size)
return FALSE; return -1;
next_pos = stream_get_pos(s) + size; next_pos = stream_get_pos(s) + size;
comp_stream = s; comp_stream = s;
@ -348,8 +352,10 @@ static BOOL fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
if (update_stream) if (update_stream)
{ {
if (!fastpath_recv_update(fastpath, updateCode, totalSize, update_stream)) status = fastpath_recv_update(fastpath, updateCode, totalSize, update_stream);
return FALSE;
if (status < 0)
return -1;
} }
stream_set_pos(s, next_pos); stream_set_pos(s, next_pos);
@ -357,24 +363,25 @@ static BOOL fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
if (comp_stream != s) if (comp_stream != s)
free(comp_stream); free(comp_stream);
return TRUE; return status;
} }
int fastpath_recv_updates(rdpFastPath* fastpath, STREAM* s) int fastpath_recv_updates(rdpFastPath* fastpath, STREAM* s)
{ {
int status = 0;
rdpUpdate* update = fastpath->rdp->update; rdpUpdate* update = fastpath->rdp->update;
IFCALL(update->BeginPaint, update->context); IFCALL(update->BeginPaint, update->context);
while (stream_get_left(s) >= 3) while (stream_get_left(s) >= 3)
{ {
if (!fastpath_recv_update_data(fastpath, s)) if (fastpath_recv_update_data(fastpath, s) < 0)
return -1; return -1;
} }
IFCALL(update->EndPaint, update->context); IFCALL(update->EndPaint, update->context);
return 0; return status;
} }
static BOOL fastpath_read_input_event_header(STREAM* s, BYTE* eventFlags, BYTE* eventCode) static BOOL fastpath_read_input_event_header(STREAM* s, BYTE* eventFlags, BYTE* eventCode)

View File

@ -677,6 +677,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, STREAM* s, int length, UINT16 securityFlags)
if (stream_get_left(s) < 12) if (stream_get_left(s) < 12)
return FALSE; return FALSE;
stream_read_UINT16(s, len); /* 0x10 */ stream_read_UINT16(s, len); /* 0x10 */
stream_read_BYTE(s, version); /* 0x1 */ stream_read_BYTE(s, version); /* 0x1 */
stream_read_BYTE(s, pad); stream_read_BYTE(s, pad);
@ -789,8 +790,10 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, STREAM* s)
while (stream_get_left(s) > 3) while (stream_get_left(s) > 3)
{ {
stream_get_mark(s, nextp); stream_get_mark(s, nextp);
if (!rdp_read_share_control_header(s, &pduLength, &pduType, &pduSource)) if (!rdp_read_share_control_header(s, &pduLength, &pduType, &pduSource))
return -1; return -1;
nextp += pduLength; nextp += pduLength;
rdp->settings->PduSource = pduSource; rdp->settings->PduSource = pduSource;
@ -832,6 +835,7 @@ static int rdp_recv_fastpath_pdu(rdpRdp* rdp, STREAM* s)
rdpFastPath* fastpath; rdpFastPath* fastpath;
fastpath = rdp->fastpath; fastpath = rdp->fastpath;
if (!fastpath_read_header_rdp(fastpath, s, &length)) if (!fastpath_read_header_rdp(fastpath, s, &length))
return -1; return -1;
@ -844,6 +848,7 @@ static int rdp_recv_fastpath_pdu(rdpRdp* rdp, STREAM* s)
if (fastpath->encryptionFlags & FASTPATH_OUTPUT_ENCRYPTED) if (fastpath->encryptionFlags & FASTPATH_OUTPUT_ENCRYPTED)
{ {
UINT16 flags = (fastpath->encryptionFlags & FASTPATH_OUTPUT_SECURE_CHECKSUM) ? SEC_SECURE_CHECKSUM : 0; UINT16 flags = (fastpath->encryptionFlags & FASTPATH_OUTPUT_SECURE_CHECKSUM) ? SEC_SECURE_CHECKSUM : 0;
if (!rdp_decrypt(rdp, s, length, flags)) if (!rdp_decrypt(rdp, s, length, flags))
return -1; return -1;
} }

View File

@ -25,13 +25,14 @@
#include "surface.h" #include "surface.h"
static BOOL update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s, UINT32 *length) static int update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s, UINT32 *length)
{ {
int pos; int pos;
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command; SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
if (stream_get_left(s) < 20) if (stream_get_left(s) < 20)
return FALSE; return -1;
stream_read_UINT16(s, cmd->destLeft); stream_read_UINT16(s, cmd->destLeft);
stream_read_UINT16(s, cmd->destTop); stream_read_UINT16(s, cmd->destTop);
stream_read_UINT16(s, cmd->destRight); stream_read_UINT16(s, cmd->destRight);
@ -42,17 +43,19 @@ static BOOL update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s, UINT3
stream_read_UINT16(s, cmd->width); stream_read_UINT16(s, cmd->width);
stream_read_UINT16(s, cmd->height); stream_read_UINT16(s, cmd->height);
stream_read_UINT32(s, cmd->bitmapDataLength); stream_read_UINT32(s, cmd->bitmapDataLength);
if (stream_get_left(s) < cmd->bitmapDataLength) if (stream_get_left(s) < cmd->bitmapDataLength)
return FALSE; return -1;
pos = stream_get_pos(s) + cmd->bitmapDataLength; pos = stream_get_pos(s) + cmd->bitmapDataLength;
cmd->bitmapData = stream_get_tail(s); cmd->bitmapData = stream_get_tail(s);
IFCALL(update->SurfaceBits, update->context, cmd); IFCALL(update->SurfaceBits, update->context, cmd);
stream_set_pos(s, pos); stream_set_pos(s, pos);
*length = 20 + cmd->bitmapDataLength; *length = 20 + cmd->bitmapDataLength;
return TRUE;
return 0;
} }
static void update_send_frame_acknowledge(rdpRdp* rdp, UINT32 frameId) static void update_send_frame_acknowledge(rdpRdp* rdp, UINT32 frameId)
@ -64,24 +67,28 @@ static void update_send_frame_acknowledge(rdpRdp* rdp, UINT32 frameId)
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FRAME_ACKNOWLEDGE, rdp->mcs->user_id); rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FRAME_ACKNOWLEDGE, rdp->mcs->user_id);
} }
static BOOL update_recv_surfcmd_frame_marker(rdpUpdate* update, STREAM* s, UINT32 *length) static int update_recv_surfcmd_frame_marker(rdpUpdate* update, STREAM* s, UINT32 *length)
{ {
SURFACE_FRAME_MARKER* marker = &update->surface_frame_marker; SURFACE_FRAME_MARKER* marker = &update->surface_frame_marker;
if (stream_get_left(s) < 6) if (stream_get_left(s) < 6)
return FALSE; return -1;
stream_read_UINT16(s, marker->frameAction); stream_read_UINT16(s, marker->frameAction);
stream_read_UINT32(s, marker->frameId); stream_read_UINT32(s, marker->frameId);
IFCALL(update->SurfaceFrameMarker, update->context, marker); IFCALL(update->SurfaceFrameMarker, update->context, marker);
if (update->context->rdp->settings->ReceivedCapabilities[CAPSET_TYPE_FRAME_ACKNOWLEDGE] && update->context->rdp->settings->FrameAcknowledge > 0 && marker->frameAction == SURFACECMD_FRAMEACTION_END) if (update->context->rdp->settings->ReceivedCapabilities[CAPSET_TYPE_FRAME_ACKNOWLEDGE] &&
(update->context->rdp->settings->FrameAcknowledge > 0) &&
(marker->frameAction == SURFACECMD_FRAMEACTION_END))
{ {
update_send_frame_acknowledge(update->context->rdp, marker->frameId); update_send_frame_acknowledge(update->context->rdp, marker->frameId);
} }
*length = 6; *length = 6;
return TRUE;
return 0;
} }
int update_recv_surfcmds(rdpUpdate* update, UINT32 size, STREAM* s) int update_recv_surfcmds(rdpUpdate* update, UINT32 size, STREAM* s)
@ -101,12 +108,12 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, STREAM* s)
{ {
case CMDTYPE_SET_SURFACE_BITS: case CMDTYPE_SET_SURFACE_BITS:
case CMDTYPE_STREAM_SURFACE_BITS: case CMDTYPE_STREAM_SURFACE_BITS:
if (!update_recv_surfcmd_surface_bits(update, s, &cmdLength)) if (update_recv_surfcmd_surface_bits(update, s, &cmdLength) < 0)
return -1; return -1;
break; break;
case CMDTYPE_FRAME_MARKER: case CMDTYPE_FRAME_MARKER:
if (!update_recv_surfcmd_frame_marker(update, s, &cmdLength)) if (update_recv_surfcmd_frame_marker(update, s, &cmdLength) < 0)
return -1; return -1;
break; break;