mirror of https://github.com/FreeRDP/FreeRDP
[coverity] fix some warnings
* mostly dead store and identical code branches. * some possible integer overflows
This commit is contained in:
parent
3f5f53d3dc
commit
ba7fd06ec4
|
@ -636,12 +636,7 @@ static DWORD client_cli_accept_certificate(freerdp* instance)
|
|||
|
||||
if ((answer == EOF) || feof(stdin))
|
||||
{
|
||||
printf("\nError: Could not read answer from stdin.");
|
||||
|
||||
if (fromStdin)
|
||||
printf(" - Run without parameter \"--from-stdin\" to set trust.");
|
||||
|
||||
printf("\n");
|
||||
printf("\nError: Could not read answer from stdin.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,13 +142,13 @@ static int persistent_cache_read_entry_v3(rdpPersistentCache* persistent,
|
|||
WINPR_ASSERT(persistent);
|
||||
WINPR_ASSERT(entry);
|
||||
|
||||
if (fread((void*)&entry3, sizeof(entry3), 1, persistent->fp) != 1)
|
||||
if (fread(&entry3, sizeof(entry3), 1, persistent->fp) != 1)
|
||||
return -1;
|
||||
|
||||
entry->key64 = entry3.key64;
|
||||
entry->width = entry3.width;
|
||||
entry->height = entry3.height;
|
||||
entry->size = entry3.width * entry3.height * 4;
|
||||
entry->size = 4ul * entry3.width * entry3.height;
|
||||
entry->flags = 0;
|
||||
|
||||
if (entry->size > persistent->bmpSize)
|
||||
|
|
|
@ -84,8 +84,6 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* WINPR_RESTRICT pDstData, UINT32 Ds
|
|||
UINT32 backColor, UINT32 foreColor,
|
||||
const gdiPalette* WINPR_RESTRICT palette)
|
||||
{
|
||||
BOOL vFlip = 0;
|
||||
UINT32 monoStep = 0;
|
||||
const UINT32 dstBytesPerPixel = FreeRDPGetBytesPerPixel(DstFormat);
|
||||
|
||||
if (!pDstData || !pSrcData || !palette)
|
||||
|
@ -94,19 +92,13 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* WINPR_RESTRICT pDstData, UINT32 Ds
|
|||
if (nDstStep == 0)
|
||||
nDstStep = dstBytesPerPixel * nWidth;
|
||||
|
||||
vFlip = FALSE;
|
||||
monoStep = (nWidth + 7) / 8;
|
||||
const UINT32 monoStep = (nWidth + 7) / 8;
|
||||
|
||||
for (UINT32 y = 0; y < nHeight; y++)
|
||||
{
|
||||
const BYTE* monoBits = NULL;
|
||||
BYTE* pDstLine = &pDstData[((nYDst + y) * nDstStep)];
|
||||
UINT32 monoBit = 0x80;
|
||||
|
||||
if (!vFlip)
|
||||
monoBits = &pSrcData[monoStep * y];
|
||||
else
|
||||
monoBits = &pSrcData[monoStep * (nHeight - y - 1)];
|
||||
const BYTE* monoBits = &pSrcData[monoStep * y];
|
||||
|
||||
for (UINT32 x = 0; x < nWidth; x++)
|
||||
{
|
||||
|
|
|
@ -1060,12 +1060,10 @@ fail:
|
|||
static INLINE INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* WINPR_RESTRICT state,
|
||||
UINT32 numBits)
|
||||
{
|
||||
UINT32 k = 0;
|
||||
UINT32 bit = 0;
|
||||
UINT32 max = 0;
|
||||
UINT32 mag = 0;
|
||||
UINT32 sign = 0;
|
||||
WINPR_ASSERT(state);
|
||||
|
||||
wBitStream* bs = state->srl;
|
||||
WINPR_ASSERT(bs);
|
||||
|
||||
if (state->nz)
|
||||
{
|
||||
|
@ -1073,12 +1071,12 @@ static INLINE INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* WINP
|
|||
return 0;
|
||||
}
|
||||
|
||||
k = state->kp / 8;
|
||||
const UINT32 k = state->kp / 8;
|
||||
|
||||
if (!state->mode)
|
||||
{
|
||||
/* zero encoding */
|
||||
bit = (bs->accumulator & 0x80000000) ? 1 : 0;
|
||||
const UINT32 bit = (bs->accumulator & 0x80000000) ? 1 : 0;
|
||||
BitStream_Shift(bs, 1);
|
||||
|
||||
if (!bit)
|
||||
|
@ -1117,7 +1115,7 @@ static INLINE INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* WINP
|
|||
state->mode = 0; /* zero encoding is next */
|
||||
/* unary encoding */
|
||||
/* read sign bit */
|
||||
sign = (bs->accumulator & 0x80000000) ? 1 : 0;
|
||||
const UINT32 sign = (bs->accumulator & 0x80000000) ? 1 : 0;
|
||||
BitStream_Shift(bs, 1);
|
||||
|
||||
if (state->kp < 6)
|
||||
|
@ -1128,12 +1126,12 @@ static INLINE INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* WINP
|
|||
if (numBits == 1)
|
||||
return sign ? -1 : 1;
|
||||
|
||||
mag = 1;
|
||||
max = (1 << numBits) - 1;
|
||||
UINT32 mag = 1;
|
||||
const UINT32 max = (1 << numBits) - 1;
|
||||
|
||||
while (mag < max)
|
||||
{
|
||||
bit = (bs->accumulator & 0x80000000) ? 1 : 0;
|
||||
const UINT32 bit = (bs->accumulator & 0x80000000) ? 1 : 0;
|
||||
BitStream_Shift(bs, 1);
|
||||
|
||||
if (bit)
|
||||
|
|
|
@ -564,14 +564,14 @@ void freerdp_device_collection_free(rdpSettings* settings)
|
|||
if (settings->DeviceArray)
|
||||
{
|
||||
for (UINT32 index = 0; index < settings->DeviceArraySize; index++)
|
||||
freerdp_settings_set_pointer_array(settings, FreeRDP_DeviceArray, index, NULL);
|
||||
(void)freerdp_settings_set_pointer_array(settings, FreeRDP_DeviceArray, index, NULL);
|
||||
}
|
||||
|
||||
free(settings->DeviceArray);
|
||||
|
||||
freerdp_settings_set_pointer(settings, FreeRDP_DeviceArray, NULL);
|
||||
freerdp_settings_set_uint32(settings, FreeRDP_DeviceArraySize, 0);
|
||||
freerdp_settings_set_uint32(settings, FreeRDP_DeviceCount, 0);
|
||||
(void)freerdp_settings_set_pointer(settings, FreeRDP_DeviceArray, NULL);
|
||||
(void)freerdp_settings_set_uint32(settings, FreeRDP_DeviceArraySize, 0);
|
||||
(void)freerdp_settings_set_uint32(settings, FreeRDP_DeviceCount, 0);
|
||||
}
|
||||
|
||||
BOOL freerdp_static_channel_collection_del(rdpSettings* settings, const char* name)
|
||||
|
|
|
@ -575,6 +575,8 @@ BOOL per_read_numeric_string(wStream* s, UINT16 min)
|
|||
|
||||
BOOL per_write_numeric_string(wStream* s, const BYTE* num_str, UINT16 length, UINT16 min)
|
||||
{
|
||||
WINPR_ASSERT(num_str || (length == 0));
|
||||
|
||||
const UINT16 mlength = (length >= min) ? length - min : min;
|
||||
|
||||
if (!per_write_length(s, mlength))
|
||||
|
|
|
@ -1526,9 +1526,6 @@ BOOL vgids_init(vgidsContext* ctx, const char* cert, const char* privateKey, con
|
|||
if (size <= 0)
|
||||
goto init_failed;
|
||||
|
||||
if (size <= 0)
|
||||
goto init_failed;
|
||||
|
||||
cmrec.wKeyExchangeKeySizeBits = (WORD)size * 8;
|
||||
if (!vgids_ef_write_do(commonEF, VGIDS_DO_CMAPFILE, &cmrec, sizeof(cmrec)))
|
||||
goto init_failed;
|
||||
|
|
|
@ -1285,6 +1285,7 @@ static LONG smartcard_StatusW_Call(scard_call_context* smartcard, wStream* out,
|
|||
}
|
||||
|
||||
/* SCardStatusW returns number of characters, we need number of bytes */
|
||||
WINPR_ASSERT(ret.cBytes != SCARD_AUTOALLOCATE);
|
||||
ret.cBytes *= sizeof(WCHAR);
|
||||
|
||||
status = smartcard_pack_status_return(out, &ret, TRUE);
|
||||
|
|
Loading…
Reference in New Issue