From e79eee2bb1a09b103d418d37b56fba745c9bc7c1 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 25 Feb 2016 20:01:12 +0100 Subject: [PATCH] Fixed Stream API misuse. --- libfreerdp/core/capabilities.c | 8 ++++---- libfreerdp/core/gateway/http.c | 2 +- libfreerdp/core/gcc.c | 6 +++--- libfreerdp/core/mcs.c | 4 ++-- libfreerdp/core/orders.c | 4 ++-- libfreerdp/core/rdp.c | 2 +- libfreerdp/core/transport.c | 3 +-- server/Sample/sfreerdp.c | 6 +++--- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 114cfd2ee..d6e46e810 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -3392,10 +3392,10 @@ BOOL rdp_print_capability_sets(wStream* s, UINT16 numberCapabilities, BOOL recei break; } - if (s->pointer != em) + if (Stream_Pointer(s) != em) { WLog_ERR(TAG, "incorrect offset, type:0x%02X actual:%d expected:%d", - type, (int)(s->pointer - bm), (int)(em - bm)); + type, (int)(Stream_Pointer(s) - bm), (int)(em - bm)); } Stream_SetPointer(s, em); @@ -3617,10 +3617,10 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa } } - if (s->pointer != em) + if (Stream_Pointer(s) != em) { WLog_ERR(TAG, "incorrect offset, type:0x%02X actual:%d expected:%d", - type, (int)(s->pointer - bm), (int)(em - bm)); + type, (int)(Stream_Pointer(s) - bm), (int)(em - bm)); } Stream_SetPointer(s, em); diff --git a/libfreerdp/core/gateway/http.c b/libfreerdp/core/gateway/http.c index f12423f93..a3d5da350 100644 --- a/libfreerdp/core/gateway/http.c +++ b/libfreerdp/core/gateway/http.c @@ -407,7 +407,7 @@ wStream* http_request_write(HttpContext* context, HttpRequest* request) free(lines); Stream_Write(s, "\0", 1); /* append null terminator */ Stream_Rewind(s, 1); /* don't include null terminator in length */ - Stream_Length(s) = Stream_GetPosition(s); + Stream_SetLength(s, Stream_GetPosition(s)); return s; out_free: diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index c2354423e..b0a0f1b0f 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -225,7 +225,7 @@ void gcc_write_conference_create_request(wStream* s, wStream* userData) per_write_octet_string(s, h221_cs_key, 4, 4); /* h221NonStandard, client-to-server H.221 key, "Duca" */ /* userData::value (OCTET_STRING) */ - per_write_octet_string(s, userData->buffer, Stream_GetPosition(userData), 0); /* array of client data blocks */ + per_write_octet_string(s, Stream_Buffer(userData), Stream_GetPosition(userData), 0); /* array of client data blocks */ } BOOL gcc_read_conference_create_response(wStream* s, rdpMcs* mcs) @@ -319,7 +319,7 @@ void gcc_write_conference_create_response(wStream* s, wStream* userData) per_write_octet_string(s, h221_sc_key, 4, 4); /* h221NonStandard, server-to-client H.221 key, "McDn" */ /* userData (OCTET_STRING) */ - per_write_octet_string(s, userData->buffer, Stream_GetPosition(userData), 0); /* array of server data blocks */ + per_write_octet_string(s, Stream_Buffer(userData), Stream_GetPosition(userData), 0); /* array of server data blocks */ } BOOL gcc_read_client_data_blocks(wStream* s, rdpMcs* mcs, int length) @@ -508,7 +508,7 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpMcs* mcs, int length) break; } offset += blockLength; - Stream_Pointer(s) = holdp + blockLength; + Stream_SetPointer(s, holdp + blockLength); } return TRUE; diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index 8d082b155..27c9126c6 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -571,7 +571,7 @@ BOOL mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* userData) goto out; /* userData (OCTET_STRING) */ - ber_write_octet_string(tmps, userData->buffer, Stream_GetPosition(userData)); + ber_write_octet_string(tmps, Stream_Buffer(userData), Stream_GetPosition(userData)); length = Stream_GetPosition(tmps); /* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */ @@ -608,7 +608,7 @@ BOOL mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* userData) if (!mcs_write_domain_parameters(tmps, &(mcs->domainParameters))) goto out; /* userData (OCTET_STRING) */ - ber_write_octet_string(tmps, userData->buffer, Stream_GetPosition(userData)); + ber_write_octet_string(tmps, Stream_Buffer(userData), Stream_GetPosition(userData)); length = Stream_GetPosition(tmps); ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length); diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 60aed90b8..49df89add 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -1728,7 +1728,7 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ } } - Stream_Pointer(s) = phold + fastGlyph->cbData; + Stream_SetPointer(s, phold + fastGlyph->cbData); } return TRUE; @@ -3546,7 +3546,7 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags) break; } - Stream_Pointer(s) = next; + Stream_SetPointer(s, next); return TRUE; } diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index dfaa02dbf..37dc8ee26 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -1056,7 +1056,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) return FALSE; /* TODO */ } - Stream_Length(s) -= pad; + Stream_SetLength(s, Stream_Length(s) - pad); return TRUE; } diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 6f928cca1..147913f82 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -733,8 +733,7 @@ out_cleanup: transport->layer = TRANSPORT_LAYER_CLOSED; } - if (s->pool) - Stream_Release(s); + Stream_Release(s); LeaveCriticalSection(&(transport->WriteLock)); return status; diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index ba2cf9ecc..96b6c9c4b 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -449,12 +449,12 @@ BOOL tf_peer_dump_rfx(freerdp_peer* client) if (!tmp) break; - Stream_Buffer(s) = tmp; + Stream_SetBuffer(s, tmp); record.data = Stream_Buffer(s); - Stream_Capacity(s) = record.length; + Stream_SetCapacity(s, record.length); pcap_get_next_record_content(pcap_rfx, &record); - Stream_Pointer(s) = Stream_Buffer(s) + Stream_Capacity(s); + Stream_SetPointer(s, Stream_Buffer(s) + Stream_Capacity(s)); if (test_dump_rfx_realtime && test_sleep_tsdiff(&prev_seconds, &prev_useconds, record.header.ts_sec, record.header.ts_usec) == FALSE) break;