diff --git a/channels/cliprdr/cliprdr_common.c b/channels/cliprdr/cliprdr_common.c index d6552af03..1b079ad61 100644 --- a/channels/cliprdr/cliprdr_common.c +++ b/channels/cliprdr/cliprdr_common.c @@ -426,6 +426,9 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL while (Stream_GetRemainingLength(sub1) >= 4) { + if (index >= formatList->numFormats) + goto error_out; + CLIPRDR_FORMAT* format = &formats[index]; Stream_Read_UINT32(sub1, format->formatId); /* formatId (4 bytes) */ diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index 9335772a0..e489739fa 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -2114,7 +2114,7 @@ exit: if (groupDsc) { - groupDsc->cItems = clipboard->nFiles; + groupDsc->cItems = WINPR_ASSERTING_INT_CAST(UINT, clipboard->nFiles); for (size_t i = 0; i < clipboard->nFiles; i++) { diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 21e2bdb92..a42da7488 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -2895,10 +2895,10 @@ static bool sUuidEqual(const UUID* Uuid1, const UUID* Uuid2) if (!Uuid1 && !Uuid2) return false; - if (!Uuid2 && Uuid1) + if (Uuid1 && !Uuid2) return false; - if (!Uuid1 && !Uuid2) + if (!Uuid1 && Uuid2) return true; if (Uuid1->Data1 != Uuid2->Data1) diff --git a/libfreerdp/primitives/sse/prim_templates.h b/libfreerdp/primitives/sse/prim_templates.h index 9d92b0186..b512d1ba6 100644 --- a/libfreerdp/primitives/sse/prim_templates.h +++ b/libfreerdp/primitives/sse/prim_templates.h @@ -139,7 +139,6 @@ int shifts = 0; \ const _type_* sptr = pSrc; \ _type_* dptr = pDst; \ - size_t count; \ __m128i xmm0; \ if (sizeof(_type_) == 1) \ shifts = 1; \ @@ -150,10 +149,10 @@ else if (sizeof(_type_) == 8) \ shifts = 4; \ /* Use 4 128-bit SSE registers. */ \ - count = len >> (7 - shifts); \ + size_t count = len >> (7 - shifts); \ len -= count << (7 - shifts); \ xmm0 = mm_set1_epu32(val); \ - while (count--) \ + for (size_t x = 0; x < count; x++) \ { \ __m128i xmm1 = LOAD_SI128(sptr); \ sptr += (16 / sizeof(_type_)); \ @@ -179,7 +178,7 @@ /* Use a single 128-bit SSE register. */ \ count = len >> (5 - shifts); \ len -= count << (5 - shifts); \ - while (count--) \ + for (size_t x = 0; x < count; x++) \ { \ __m128i xmm1 = LOAD_SI128(sptr); \ sptr += (16 / sizeof(_type_)); \ @@ -188,7 +187,7 @@ dptr += (16 / sizeof(_type_)); \ } \ /* Finish off the remainder. */ \ - while (len--) \ + for (size_t x = 0; x < len; x++) \ { \ _slowWay_; \ } \ diff --git a/winpr/libwinpr/utils/collections/BufferPool.c b/winpr/libwinpr/utils/collections/BufferPool.c index de6682ad1..caf8a23bc 100644 --- a/winpr/libwinpr/utils/collections/BufferPool.c +++ b/winpr/libwinpr/utils/collections/BufferPool.c @@ -379,7 +379,7 @@ BOOL BufferPool_Return(wBufferPool* pool, void* buffer) if ((pool->size + 1) >= pool->capacity) { - SSIZE_T newCapacity = MAX(1, pool->size + (pool->size + 2) / 2 + 1); + SSIZE_T newCapacity = MAX(2, pool->size + (pool->size + 2) / 2 + 1); void** newArray = (void**)realloc( (void*)pool->array, sizeof(void*) * WINPR_ASSERTING_INT_CAST(size_t, newCapacity)); if (!newArray) @@ -416,7 +416,7 @@ BOOL BufferPool_Return(wBufferPool* pool, void* buffer) { if ((pool->aSize + 1) >= pool->aCapacity) { - SSIZE_T newCapacity = MAX(1, pool->aSize + (pool->aSize + 2) / 2 + 1); + SSIZE_T newCapacity = MAX(2, pool->aSize + (pool->aSize + 2) / 2 + 1); wBufferPoolItem* newArray = (wBufferPoolItem*)realloc( pool->aArray, sizeof(wBufferPoolItem) * WINPR_ASSERTING_INT_CAST(size_t, newCapacity));