[covertity] fix various warnings

This commit is contained in:
Armin Novak 2024-06-05 09:08:13 +02:00
parent b17b07885a
commit 8d783d5189
No known key found for this signature in database
GPG Key ID: 2CF4A2D2D3D72105
7 changed files with 37 additions and 16 deletions

View File

@ -607,7 +607,8 @@ static BOOL ffmpeg_decode(AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame
const size_t channels = resampled->ch_layout.nb_channels;
#endif
const size_t data_size = channels * resampled->nb_samples * 2;
Stream_EnsureRemainingCapacity(out, data_size);
if (!Stream_EnsureRemainingCapacity(out, data_size))
return FALSE;
Stream_Write(out, resampled->data[0], data_size);
}
}

View File

@ -3035,7 +3035,9 @@ static BOOL rdp_apply_bitmap_codecs_capability_set(rdpSettings* settings, const
/* only enable a codec if we've announced/enabled it before */
settings->RemoteFxCodec = settings->RemoteFxCodec && src->RemoteFxCodecId;
settings->RemoteFxImageCodec = settings->RemoteFxImageCodec && src->RemoteFxImageCodec;
freerdp_settings_set_bool(settings, FreeRDP_NSCodec, settings->NSCodec && src->NSCodec);
if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec,
settings->NSCodec && src->NSCodec))
return FALSE;
settings->JpegCodec = src->JpegCodec;
}
return TRUE;
@ -3237,10 +3239,14 @@ static BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, rdpSettings* setti
bitmapCodecCount--;
/* only enable a codec if we've announced/enabled it before */
settings->RemoteFxCodec = guidRemoteFx;
settings->RemoteFxImageCodec = guidRemoteFxImage;
freerdp_settings_set_bool(settings, FreeRDP_NSCodec, guidNSCodec);
settings->JpegCodec = FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, guidRemoteFx))
return FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxImageCodec, guidRemoteFxImage))
return FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, guidNSCodec))
return FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_JpegCodec, FALSE))
return FALSE;
}
return TRUE;
@ -4492,9 +4498,12 @@ BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s, UINT16 pduLength)
if (!settings->ReceivedCapabilities[CAPSET_TYPE_BITMAP_CODECS])
{
/* client does not support bitmap codecs */
settings->RemoteFxCodec = FALSE;
freerdp_settings_set_bool(settings, FreeRDP_NSCodec, FALSE);
settings->JpegCodec = FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, FALSE))
return FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, FALSE))
return FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_JpegCodec, FALSE))
return FALSE;
}
if (!settings->ReceivedCapabilities[CAPSET_TYPE_MULTI_FRAGMENT_UPDATE])

View File

@ -391,8 +391,10 @@ static BOOL wst_handle_ok_or_forbidden(rdpWst* wst, HttpResponse** ppresponse, D
return FALSE;
free(wst->gwpath);
wst->gwpath = urlWithAuth;
http_context_set_uri(wst->http, wst->gwpath);
http_context_enable_websocket_upgrade(wst->http, TRUE);
if (!http_context_set_uri(wst->http, wst->gwpath))
return FALSE;
if (!http_context_enable_websocket_upgrade(wst->http, TRUE))
return FALSE;
}
if (!wst_send_http_request(wst, wst->tls))

View File

@ -818,7 +818,7 @@ static int nla_server_authenticate(rdpNla* nla)
break;
}
nla_send(nla);
(void)nla_send(nla);
/* Access Denied */
goto fail;
}

View File

@ -79,16 +79,23 @@ static char* crypto_print_name(const X509_NAME* name)
{
UINT64 size = BIO_number_written(outBIO);
if (size > INT_MAX)
return NULL;
goto fail;
buffer = calloc(1, (size_t)size + 1);
if (!buffer)
return NULL;
goto fail;
ERR_clear_error();
BIO_read(outBIO, buffer, (int)size);
const int rc = BIO_read(outBIO, buffer, (int)size);
if (rc <= 0)
{
free(buffer);
buffer = NULL;
goto fail;
}
}
fail:
BIO_free_all(outBIO);
return buffer;
}

View File

@ -886,7 +886,7 @@ static WIN32_FILE_SEARCH* file_search_new(const char* name, size_t namelen, cons
if (!pFileSearch)
return NULL;
WINPR_ASSERT(sizeof(file_search_magic) == sizeof(pFileSearch->magic));
strncpy(pFileSearch->magic, file_search_magic, sizeof(pFileSearch->magic));
memcpy(pFileSearch->magic, file_search_magic, sizeof(pFileSearch->magic));
pFileSearch->lpPath = strndup(name, namelen);
pFileSearch->lpPattern = strndup(pattern, patternlen);

View File

@ -830,6 +830,8 @@ static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(
if (context->state == NEGOTIATE_STATE_NEGORESP)
{
/* Store the mech token in the output buffer */
if (!output_buffer)
goto cleanup;
CopyMemory(&output_token.mechToken, output_buffer, sizeof(SecBuffer));
mech_input_buffers[0] = input_token.mechToken;