diff --git a/client/common/file.c b/client/common/file.c index 130a8cb3a..593a2217b 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -1357,19 +1357,16 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSett BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL unicode) { - FILE* fp = NULL; - size_t size = 0; - char* buffer = NULL; int status = 0; WCHAR* unicodestr = NULL; if (!file || !name) return FALSE; - size = freerdp_client_write_rdp_file_buffer(file, NULL, 0); + const size_t size = freerdp_client_write_rdp_file_buffer(file, NULL, 0); if (size == 0) return FALSE; - buffer = (char*)calloc((size_t)(size + 1), sizeof(char)); + char* buffer = calloc(size + 1ULL, sizeof(char)); if (freerdp_client_write_rdp_file_buffer(file, buffer, size + 1) != size) { @@ -1378,7 +1375,7 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u return FALSE; } - fp = winpr_fopen(name, "w+b"); + FILE* fp = winpr_fopen(name, "w+b"); if (fp) { diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c index dd5ae1d71..4e35ceef1 100644 --- a/libfreerdp/cache/bitmap.c +++ b/libfreerdp/cache/bitmap.c @@ -326,7 +326,10 @@ static int bitmap_cache_save_persistent(rdpBitmapCache* bitmapCache) cacheEntry.key64 = bitmap->key64; cacheEntry.width = bitmap->width; cacheEntry.height = bitmap->height; - cacheEntry.size = (UINT32)(bitmap->width * bitmap->height * 4); + const UINT64 size = 4ULL * bitmap->width * bitmap->height; + if (size > UINT32_MAX) + continue; + cacheEntry.size = (UINT32)size; cacheEntry.flags = 0; cacheEntry.data = bitmap->data; diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index fbbc33ae5..2bf7ff553 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -2011,9 +2011,9 @@ BOOL gcc_read_client_cluster_data(wStream* s, rdpMcs* mcs) settings->RedirectSmartCards = (settings->ClusterInfoFlags & REDIRECTED_SMARTCARD) ? TRUE : FALSE; - if (blockLength != 8) + if (blockLength > 8ULL) { - if (Stream_GetRemainingLength(s) >= (size_t)(blockLength - 8)) + if (Stream_GetRemainingLength(s) >= (blockLength - 8ULL)) { /* The old Microsoft Mac RDP client can send a pad here */ Stream_Seek(s, (blockLength - 8)); diff --git a/libfreerdp/primitives/prim_colors.c b/libfreerdp/primitives/prim_colors.c index 4448a3319..550fc8687 100644 --- a/libfreerdp/primitives/prim_colors.c +++ b/libfreerdp/primitives/prim_colors.c @@ -91,9 +91,6 @@ static pstatus_t general_yCbCrToRGB_16s8u_P3AC4R_general(const INT16* const WINP { for (UINT32 x = 0; x < roi->width; x++) { - INT64 R = 0; - INT64 G = 0; - INT64 B = 0; const INT32 divisor = 16; const INT32 Y = (INT32)((UINT32)((*pY++) + 4096) << divisor); const INT32 Cb = (*pCb++); @@ -102,9 +99,9 @@ static pstatus_t general_yCbCrToRGB_16s8u_P3AC4R_general(const INT16* const WINP const INT64 CrG = Cr * (INT64)(0.714401f * (1 << divisor)) * 1LL; const INT64 CbG = Cb * (INT64)(0.343730f * (1 << divisor)) * 1LL; const INT64 CbB = Cb * (INT64)(1.769905f * (1 << divisor)) * 1LL; - R = (INT64)((CrR + Y) >> (divisor + 5)); - G = (INT64)((Y - CbG - CrG) >> (divisor + 5)); - B = (INT64)((CbB + Y) >> (divisor + 5)); + const INT64 R = (CrR + Y) >> (divisor + 5); + const INT64 G = (Y - CbG - CrG) >> (divisor + 5); + const INT64 B = (CbB + Y) >> (divisor + 5); pRGB = writePixel(pRGB, formatSize, DstFormat, CLIP(R), CLIP(G), CLIP(B), 0); }