libfreerdp-core: fix handling of uncompressed packets
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Wed, 26 Mar 2014 13:16:28 +0000 (09:16 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Wed, 26 Mar 2014 13:16:28 +0000 (09:16 -0400)
libfreerdp/core/bulk.c
libfreerdp/core/fastpath.c

index 1b12738..4956b00 100644 (file)
@@ -77,7 +77,7 @@ int bulk_decompress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstD
        {
                *ppDstData = pSrcData;
                *pDstSize = SrcSize;
-               status = 1;
+               status = 0;
        }
 
        if (status >= 0)
index ba9af73..9d51575 100644 (file)
@@ -337,6 +337,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
        rdpRdp* rdp;
        int next_pos;
        wStream* cs;
+       int bulkStatus;
        UINT32 totalSize;
        BYTE updateCode;
        BYTE fragmentation;
@@ -365,8 +366,18 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
        cs = s;
        next_pos = Stream_GetPosition(s) + size;
 
-       if (bulk_decompress(rdp->bulk, Stream_Pointer(s), size, &pDstData, &DstSize, compressionFlags))
+       bulkStatus = bulk_decompress(rdp->bulk, Stream_Pointer(s), size, &pDstData, &DstSize, compressionFlags);
+
+       if (bulkStatus < 0)
+       {
+               fprintf(stderr, "bulk_decompress() failed\n");
+               return -1;
+       }
+
+       if (bulkStatus > 0)
        {
+               /* data was compressed, copy from decompression buffer */
+
                size = DstSize;
                cs = StreamPool_Take(transport->ReceivePool, DstSize);
 
@@ -375,11 +386,6 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
                Stream_SealLength(cs);
                Stream_SetPosition(cs, 0);
        }
-       else
-       {
-               fprintf(stderr, "bulk_decompress() failed\n");
-               Stream_Seek(s, size);
-       }
 
        if (fragmentation == FASTPATH_FRAGMENT_SINGLE)
        {