diff --git a/libfreerdp/codec/include/bitmap.c b/libfreerdp/codec/include/bitmap.c index 734ed13..602d1b3 100644 --- a/libfreerdp/codec/include/bitmap.c +++ b/libfreerdp/codec/include/bitmap.c @@ -338,10 +338,6 @@ static INLINE BOOL RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer, case MEGA_MEGA_COLOR_IMAGE: runLength = ExtractRunLength(code, pbSrc, &advance); pbSrc = pbSrc + advance; - - if (!ENSURE_CAPACITY(pbDest, pbDestEnd, runLength)) - return FALSE; - UNROLL(runLength, { SRCREADPIXEL(temp, pbSrc); diff --git a/libfreerdp/codec/interleaved.c b/libfreerdp/codec/interleaved.c index 0d36e9b..a3fe7dd 100644 --- a/libfreerdp/codec/interleaved.c +++ b/libfreerdp/codec/interleaved.c @@ -215,7 +215,7 @@ static INLINE BOOL ensure_capacity(const BYTE* start, const BYTE* end, size_t si { const size_t available = (uintptr_t)end - (uintptr_t)start; const BOOL rc = available >= size * base; - return rc && (start <= end); + return rc; } static INLINE void write_pixel_8(BYTE* _buf, BYTE _pix) diff --git a/libfreerdp/codec/planar.c b/libfreerdp/codec/planar.c index 34c48d7..98f2495 100644 --- a/libfreerdp/codec/planar.c +++ b/libfreerdp/codec/planar.c @@ -42,9 +42,10 @@ static INLINE BYTE* freerdp_bitmap_planar_delta_encode_plane( static INLINE INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, UINT32 nWidth, UINT32 nHeight) { - UINT32 used = 0; UINT32 x, y; BYTE controlByte; + const BYTE* pRLE = pSrcData; + const BYTE* pEnd = &pSrcData[SrcSize]; for (y = 0; y < nHeight; y++) { @@ -53,10 +54,10 @@ static INLINE INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, int cRawBytes; int nRunLength; - if (used >= SrcSize) + if (pRLE >= pEnd) return -1; - controlByte = pSrcData[used++]; + controlByte = *pRLE++; nRunLength = PLANAR_CONTROL_BYTE_RUN_LENGTH(controlByte); cRawBytes = PLANAR_CONTROL_BYTE_RAW_BYTES(controlByte); @@ -71,21 +72,19 @@ static INLINE INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, cRawBytes = 0; } - used += cRawBytes; + pRLE += cRawBytes; x += cRawBytes; x += nRunLength; if (x > nWidth) return -1; - if (used > SrcSize) + if (pRLE > pEnd) return -1; } } - if (used > INT32_MAX) - return -1; - return (INT32)used; + return (INT32)(pRLE - pSrcData); } static INLINE INT32 planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index e44f0de..9f3489f 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -1961,9 +1961,6 @@ static CACHE_BITMAP_ORDER* update_read_cache_bitmap_order(rdpUpdate* update, wSt } } - if (cache_bitmap->bitmapLength == 0) - goto fail; - if (Stream_GetRemainingLength(s) < cache_bitmap->bitmapLength) goto fail; @@ -2098,9 +2095,6 @@ static CACHE_BITMAP_V2_ORDER* update_read_cache_bitmap_v2_order(rdpUpdate* updat } } - if (cache_bitmap_v2->bitmapLength == 0) - goto fail; - if (Stream_GetRemainingLength(s) < cache_bitmap_v2->bitmapLength) goto fail; diff --git a/libfreerdp/gdi/region.c b/libfreerdp/gdi/region.c index 1ffbf79..d3b28b5 100644 --- a/libfreerdp/gdi/region.c +++ b/libfreerdp/gdi/region.c @@ -37,19 +37,6 @@ #define TAG FREERDP_TAG("gdi.region") -static char* gdi_rect_str(char* buffer, size_t size, const HGDI_RECT rect) -{ - if (!buffer || (size < 1) || !rect) - return NULL; - - _snprintf(buffer, size - 1, - "[top/left=%" PRId32 "x%" PRId32 "-bottom/right%" PRId32 "x%" PRId32 "]", rect->top, - rect->left, rect->bottom, rect->right); - buffer[size - 1] = '\0'; - - return buffer; -} - /** * Create a region from rectangular coordinates.\n * @msdn{dd183514} @@ -147,29 +134,10 @@ INLINE void gdi_RectToCRgn(const HGDI_RECT rect, INT32* x, INT32* y, INT32* w, INT32* h) { - INT64 tmp; *x = rect->left; *y = rect->top; - tmp = rect->right - rect->left + 1; - if ((tmp < 0) || (tmp > INT32_MAX)) - { - char buffer[256]; - WLog_ERR(TAG, "[%s] rectangle invalid %s", __FUNCTION__, - gdi_rect_str(buffer, sizeof(buffer), rect)); - *w = 0; - } - else - *w = tmp; - tmp = rect->bottom - rect->top + 1; - if ((tmp < 0) || (tmp > INT32_MAX)) - { - char buffer[256]; - WLog_ERR(TAG, "[%s] rectangle invalid %s", __FUNCTION__, - gdi_rect_str(buffer, sizeof(buffer), rect)); - *h = 0; - } - else - *h = tmp; + *w = rect->right - rect->left + 1; + *h = rect->bottom - rect->top + 1; } /**