From 41bd8bd3fb77e3ca626f990d74f2f3b97485b6a7 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 4 Aug 2023 14:29:59 +0200 Subject: [PATCH] [various] fix integer conversions --- channels/cliprdr/server/cliprdr_main.c | 3 +-- channels/rdpecam/server/camera_device_main.c | 3 +-- channels/rdpsnd/server/rdpsnd_main.c | 6 ++---- rdtk/librdtk/rdtk_nine_patch.c | 5 +++-- server/Sample/sfreerdp.c | 2 +- server/proxy/modules/capture/cap_main.c | 4 ++-- server/shadow/X11/x11_shadow.c | 8 +++---- server/shadow/shadow_rdpsnd.c | 22 +++++--------------- server/shadow/shadow_surface.c | 2 +- 9 files changed, 20 insertions(+), 35 deletions(-) diff --git a/channels/cliprdr/server/cliprdr_main.c b/channels/cliprdr/server/cliprdr_main.c index 28e0c4f6b..73279ac97 100644 --- a/channels/cliprdr/server/cliprdr_main.c +++ b/channels/cliprdr/server/cliprdr_main.c @@ -514,7 +514,6 @@ static UINT cliprdr_server_receive_general_capability(CliprdrServerContext* cont static UINT cliprdr_server_receive_capabilities(CliprdrServerContext* context, wStream* s, const CLIPRDR_HEADER* header) { - UINT16 index; UINT16 capabilitySetType; UINT16 capabilitySetLength; UINT error = ERROR_INVALID_DATA; @@ -532,7 +531,7 @@ static UINT cliprdr_server_receive_capabilities(CliprdrServerContext* context, w Stream_Read_UINT16(s, capabilities.cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */ Stream_Seek_UINT16(s); /* pad1 (2 bytes) */ - for (index = 0; index < capabilities.cCapabilitiesSets; index++) + for (size_t index = 0; index < capabilities.cCapabilitiesSets; index++) { void* tmp = NULL; if (!Stream_CheckAndLogRequiredLength(TAG, s, 4)) diff --git a/channels/rdpecam/server/camera_device_main.c b/channels/rdpecam/server/camera_device_main.c index 80c101d9e..5a13e8bae 100644 --- a/channels/rdpecam/server/camera_device_main.c +++ b/channels/rdpecam/server/camera_device_main.c @@ -202,7 +202,6 @@ static UINT device_server_recv_media_type_list_response(CameraDeviceServerContex { CAM_MEDIA_TYPE_LIST_RESPONSE pdu = { 0 }; UINT error = CHANNEL_RC_OK; - BYTE i; WINPR_ASSERT(context); WINPR_ASSERT(header); @@ -222,7 +221,7 @@ static UINT device_server_recv_media_type_list_response(CameraDeviceServerContex return ERROR_NOT_ENOUGH_MEMORY; } - for (i = 0; i < pdu.N_Descriptions; ++i) + for (size_t i = 0; i < pdu.N_Descriptions; ++i) { CAM_MEDIA_TYPE_DESCRIPTION* MediaTypeDescriptions = &pdu.MediaTypeDescriptions[i]; diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c index 60b81dfa6..3ad7070a7 100644 --- a/channels/rdpsnd/server/rdpsnd_main.c +++ b/channels/rdpsnd/server/rdpsnd_main.c @@ -55,8 +55,6 @@ static wStream* rdpsnd_server_get_buffer(RdpsndServerContext* context) static UINT rdpsnd_server_send_formats(RdpsndServerContext* context) { wStream* s = rdpsnd_server_get_buffer(context); - size_t pos; - UINT16 i; BOOL status = FALSE; ULONG written; @@ -75,7 +73,7 @@ static UINT rdpsnd_server_send_formats(RdpsndServerContext* context) Stream_Write_UINT16(s, CHANNEL_VERSION_WIN_MAX); /* wVersion */ Stream_Write_UINT8(s, 0); /* bPad */ - for (i = 0; i < context->num_server_formats; i++) + for (size_t i = 0; i < context->num_server_formats; i++) { const AUDIO_FORMAT* format = &context->server_formats[i]; @@ -83,7 +81,7 @@ static UINT rdpsnd_server_send_formats(RdpsndServerContext* context) goto fail; } - pos = Stream_GetPosition(s); + const size_t pos = Stream_GetPosition(s); Stream_SetPosition(s, 2); Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); diff --git a/rdtk/librdtk/rdtk_nine_patch.c b/rdtk/librdtk/rdtk_nine_patch.c index b1e686507..2d5025c1a 100644 --- a/rdtk/librdtk/rdtk_nine_patch.c +++ b/rdtk/librdtk/rdtk_nine_patch.c @@ -356,8 +356,9 @@ static BOOL rdtk_nine_patch_get_fill_ht(rdtkNinePatch* ninePatch, wImage* image) for (uint32_t y = 1; y < image->height - 1; y++) { - const uint32_t* pixel = (uint32_t*)&image->data[((image->width - 1) * sizeof(uint32_t)) + - image->scanline * y]; /* (width - 1, 1) */ + const uint32_t* pixel = + (uint32_t*)&image->data[((image->width - 1) * sizeof(uint32_t)) + + image->scanline * y * 1ull]; /* (width - 1, 1) */ if (beg < 0) { if (*pixel) diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 26cd3179d..58a36bbbe 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -366,7 +366,7 @@ static BOOL test_peer_load_icon(freerdp_peer* client) if (!(context->bg_data = calloc(context->icon_height, context->icon_width * 3))) goto out_fail; - memset(context->bg_data, 0xA0, context->icon_width * context->icon_height * 3); + memset(context->bg_data, 0xA0, context->icon_width * context->icon_height * 3ull); context->icon_data = rgb_data; fclose(fp); return TRUE; diff --git a/server/proxy/modules/capture/cap_main.c b/server/proxy/modules/capture/cap_main.c index 77d7f3928..a8a108879 100644 --- a/server/proxy/modules/capture/cap_main.c +++ b/server/proxy/modules/capture/cap_main.c @@ -162,8 +162,8 @@ static BOOL capture_plugin_send_frame(pClientContext* pc, SOCKET socket, const B settings = pc->context.settings; WINPR_ASSERT(settings); - frame_size = settings->DesktopWidth * settings->DesktopHeight * - (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) / 8); + frame_size = settings->DesktopWidth * settings->DesktopHeight * 1ull * + (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) / 8ull); bmp_header = winpr_bitmap_construct_header(settings->DesktopWidth, settings->DesktopHeight, freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth)); diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index 606ae1458..a4762bafe 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -1116,9 +1116,9 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem) return -1; } - subsystem->fb_shm_info.shmid = - shmget(IPC_PRIVATE, subsystem->fb_image->bytes_per_line * subsystem->fb_image->height, - IPC_CREAT | 0600); + subsystem->fb_shm_info.shmid = shmget( + IPC_PRIVATE, subsystem->fb_image->bytes_per_line * subsystem->fb_image->height * 1ull, + IPC_CREAT | 0600); if (subsystem->fb_shm_info.shmid == -1) { @@ -1333,7 +1333,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub) subsystem->cursorMaxWidth = 256; subsystem->cursorMaxHeight = 256; subsystem->cursorPixels = - winpr_aligned_malloc(subsystem->cursorMaxWidth * subsystem->cursorMaxHeight * 4, 16); + winpr_aligned_malloc(subsystem->cursorMaxWidth * subsystem->cursorMaxHeight * 4ull, 16); if (!subsystem->cursorPixels) return -1; diff --git a/server/shadow/shadow_rdpsnd.c b/server/shadow/shadow_rdpsnd.c index cacd3e7f1..fa6c7e38b 100644 --- a/server/shadow/shadow_rdpsnd.c +++ b/server/shadow/shadow_rdpsnd.c @@ -31,31 +31,19 @@ static void rdpsnd_activated(RdpsndServerContext* context) { - const AUDIO_FORMAT* agreed_format = NULL; - UINT16 i = 0, j = 0; - - for (i = 0; i < context->num_client_formats; i++) + for (size_t i = 0; i < context->num_client_formats; i++) { - for (j = 0; j < context->num_server_formats; j++) + for (size_t j = 0; j < context->num_server_formats; j++) { if (audio_format_compatible(&context->server_formats[j], &context->client_formats[i])) { - agreed_format = &context->server_formats[j]; - break; + context->SelectFormat(context, i); + return; } } - - if (agreed_format != NULL) - break; } - if (agreed_format == NULL) - { - WLog_ERR(TAG, "Could not agree on a audio format with the server\n"); - return; - } - - context->SelectFormat(context, i); + WLog_ERR(TAG, "Could not agree on a audio format with the server\n"); } int shadow_client_rdpsnd_init(rdpShadowClient* client) diff --git a/server/shadow/shadow_surface.c b/server/shadow/shadow_surface.c index d4e3ebf81..21a7e379d 100644 --- a/server/shadow/shadow_surface.c +++ b/server/shadow/shadow_surface.c @@ -87,7 +87,7 @@ BOOL shadow_surface_resize(rdpShadowSurface* surface, UINT16 x, UINT16 y, UINT32 return TRUE; } - buffer = (BYTE*)realloc(surface->data, scanline * ALIGN_SCREEN_SIZE(height, 4)); + buffer = (BYTE*)realloc(surface->data, scanline * ALIGN_SCREEN_SIZE(height, 4) * 1ull); if (buffer) {