diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 925d9ab17..26b29d1b2 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -70,7 +70,8 @@ static BOOL delete_surface(const void* key, void* value, void* arg) static void free_surfaces(RdpgfxClientContext* context, wHashTable* SurfaceTable) { - HashTable_Foreach(SurfaceTable, delete_surface, context); + if (!HashTable_Foreach(SurfaceTable, delete_surface, context)) + WLog_WARN(TAG, "delete_surface failed"); } static UINT evict_cache_slots(RdpgfxClientContext* context, UINT16 MaxCacheSlots, void** CacheSlots) diff --git a/channels/urbdrc/client/libusb/libusb_udevman.c b/channels/urbdrc/client/libusb/libusb_udevman.c index 13aed81d9..4a640469b 100644 --- a/channels/urbdrc/client/libusb/libusb_udevman.c +++ b/channels/urbdrc/client/libusb/libusb_udevman.c @@ -723,7 +723,8 @@ static UINT urbdrc_udevman_parse_addin_args(UDEVMAN* udevman, const ADDIN_ARGV* const char* arg = args->argv[x]; if (strcmp(arg, "dbg") == 0) { - WLog_SetLogLevel(WLog_Get(TAG), WLOG_TRACE); + if (!WLog_SetLogLevel(WLog_Get(TAG), WLOG_TRACE)) + return ERROR_INTERNAL_ERROR; } else if (_strnicmp(arg, "device:", 7) == 0) { diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index 7cc437aa0..f50ca3933 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -890,7 +890,8 @@ static UINT urbdrc_process_addin_args(URBDRC_PLUGIN* urbdrc, const ADDIN_ARGV* a CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dbg") { - WLog_SetLogLevel(urbdrc->log, WLOG_TRACE); + if (!WLog_SetLogLevel(urbdrc->log, WLOG_TRACE)) + return ERROR_INTERNAL_ERROR; } CommandLineSwitchCase(arg, "sys") { diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c index cd173355c..e03757139 100644 --- a/client/X11/cli/xfreerdp.c +++ b/client/X11/cli/xfreerdp.c @@ -108,7 +108,8 @@ int main(int argc, char* argv[]) thread = freerdp_client_get_thread(context); (void)WaitForSingleObject(thread, INFINITE); - GetExitCodeThread(thread, &dwExitCode); + if (!GetExitCodeThread(thread, &dwExitCode)) + goto out; rc = xf_exit_code_from_disconnect_reason(dwExitCode); freerdp_client_stop(context); diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 9cdec0b4d..03f725cb0 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -754,7 +754,11 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig LogDynAndXClearWindow(xfc->log, xfc->display, window->handle); xf_SetWindowTitleText(xfc, window->handle, name); LogDynAndXMapWindow(xfc->log, xfc->display, window->handle); - xf_input_init(xfc, window->handle); + if (!xf_input_init(xfc, window->handle)) + { + xf_DestroyDesktopWindow(xfc, window); + return nullptr; + } /* * NOTE: This must be done here to handle reparenting the window, diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index ce5f6491c..bbf0f67af 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -549,15 +549,20 @@ static BOOL clear_clip_data_entries(WINPR_ATTR_UNUSED const void* key, void* val return TRUE; } -static void clear_cdi_entries(CliprdrFileContext* file_context) +WINPR_ATTR_NODISCARD +static UINT clear_cdi_entries(CliprdrFileContext* file_context) { + UINT res = CHANNEL_RC_OK; WINPR_ASSERT(file_context); HashTable_Lock(file_context->inode_table); - HashTable_Foreach(file_context->clip_data_table, clear_clip_data_entries, nullptr); + if (!HashTable_Foreach(file_context->clip_data_table, clear_clip_data_entries, nullptr)) + res = ERROR_INTERNAL_ERROR; HashTable_Clear(file_context->clip_data_table); HashTable_Unlock(file_context->inode_table); + + return res; } static UINT prepare_clip_data_entry_with_id(CliprdrFileContext* file_context) @@ -616,7 +621,7 @@ UINT cliprdr_file_context_notify_new_server_format_list(CliprdrFileContext* file #if defined(WITH_FUSE) clear_no_cdi_entry(file_context); /* TODO: assign timeouts to old locks instead */ - clear_cdi_entries(file_context); + rc = clear_cdi_entries(file_context); if (does_server_support_clipdata_locking(file_context)) rc = prepare_clip_data_entry_with_id(file_context); @@ -634,7 +639,7 @@ UINT cliprdr_file_context_notify_new_client_format_list(CliprdrFileContext* file #if defined(WITH_FUSE) clear_no_cdi_entry(file_context); /* TODO: assign timeouts to old locks instead */ - clear_cdi_entries(file_context); + return clear_cdi_entries(file_context); #endif return CHANNEL_RC_OK; diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 941cc9d22..8651d15fc 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -5606,7 +5606,6 @@ static int freerdp_client_settings_parse_command_line_arguments_int( if (!isArgsFrom) warn_credential_args(largs); - CommandLineFindArgumentA(largs, "v"); arg = largs; errno = 0; diff --git a/libfreerdp/emu/scard/smartcard_virtual_gids.c b/libfreerdp/emu/scard/smartcard_virtual_gids.c index 42e77cf81..3ec3053b2 100644 --- a/libfreerdp/emu/scard/smartcard_virtual_gids.c +++ b/libfreerdp/emu/scard/smartcard_virtual_gids.c @@ -663,9 +663,10 @@ static BOOL vgids_read_do_fkt(void* data, size_t index, va_list ap) return TRUE; } -static void vgids_read_do(vgidsContext* context, UINT16 efID, UINT16 doID) +WINPR_ATTR_NODISCARD +static BOOL vgids_read_do(vgidsContext* context, UINT16 efID, UINT16 doID) { - ArrayList_ForEach(context->files, vgids_read_do_fkt, context, efID, doID); + return ArrayList_ForEach(context->files, vgids_read_do_fkt, context, efID, doID); } static void vgids_reset_context_response(vgidsContext* context) @@ -897,7 +898,8 @@ static BOOL vgids_ins_getdata(vgidsContext* context, wStream* s, BYTE** response } Stream_Read_UINT16_BE(s, doId); - vgids_read_do(context, fileId, doId); + if (!vgids_read_do(context, fileId, doId)) + return FALSE; break; } case 0xA: diff --git a/server/proxy/channels/pf_channel_smartcard.c b/server/proxy/channels/pf_channel_smartcard.c index c2af7fd00..c6e2f8953 100644 --- a/server/proxy/channels/pf_channel_smartcard.c +++ b/server/proxy/channels/pf_channel_smartcard.c @@ -151,12 +151,15 @@ static BOOL start_irp_thread(pf_channel_client_context* scard, work = CreateThreadpoolWork(irp_thread, arg, nullptr); if (!work) goto fail; - ArrayList_Append(scard->workObjects, work); + if (!ArrayList_Append(scard->workObjects, work)) + goto fail; SubmitThreadpoolWork(work); return TRUE; fail: + if (work) + CloseThreadpoolWork(work); if (arg) queue_free(arg->e); free(arg); diff --git a/server/proxy/pf_modules.c b/server/proxy/pf_modules.c index dbfea2251..5e9ee6df8 100644 --- a/server/proxy/pf_modules.c +++ b/server/proxy/pf_modules.c @@ -483,7 +483,7 @@ static BOOL pf_modules_print_ArrayList_ForEachFkt(void* data, size_t index, va_l return TRUE; } -void pf_modules_list_loaded_plugins(proxyModule* module) +BOOL pf_modules_list_loaded_plugins(proxyModule* module) { size_t count = 0; @@ -495,7 +495,7 @@ void pf_modules_list_loaded_plugins(proxyModule* module) if (count > 0) WLog_INFO(TAG, "Loaded plugins:"); - ArrayList_ForEach(module->plugins, pf_modules_print_ArrayList_ForEachFkt); + return ArrayList_ForEach(module->plugins, pf_modules_print_ArrayList_ForEachFkt); } WINPR_ATTR_NODISCARD diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 2df961929..3df04a6c1 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -970,7 +970,9 @@ proxyServer* pf_server_new(const proxyConfig* config) goto out; } - pf_modules_list_loaded_plugins(server->module); + if (!pf_modules_list_loaded_plugins(server->module)) + goto out; + if (!are_all_required_modules_loaded(server->module, server->config)) goto out; diff --git a/server/proxy/proxy_modules.h b/server/proxy/proxy_modules.h index 0979501af..1f30da515 100644 --- a/server/proxy/proxy_modules.h +++ b/server/proxy/proxy_modules.h @@ -90,7 +90,7 @@ extern "C" WINPR_ATTR_NODISCARD BOOL pf_modules_is_plugin_loaded(proxyModule* module, const char* plugin_name); - void pf_modules_list_loaded_plugins(proxyModule* module); + WINPR_ATTR_NODISCARD BOOL pf_modules_list_loaded_plugins(proxyModule* module); WINPR_ATTR_NODISCARD BOOL pf_modules_run_filter(proxyModule* module, PF_FILTER_TYPE type, proxyData* pdata, void* param); diff --git a/winpr/include/winpr/collections.h b/winpr/include/winpr/collections.h index b090f7a0f..a1795e132 100644 --- a/winpr/include/winpr/collections.h +++ b/winpr/include/winpr/collections.h @@ -822,7 +822,6 @@ extern "C" WINPR_API void MessagePipe_Free(wMessagePipe* pipe); WINPR_ATTR_MALLOC(MessagePipe_Free, 1) - WINPR_ATTR_NODISCARD WINPR_API wMessagePipe* MessagePipe_New(void); /* Publisher/Subscriber Pattern */ diff --git a/winpr/libwinpr/clipboard/synthetic.c b/winpr/libwinpr/clipboard/synthetic.c index 550a1a462..1fac5b693 100644 --- a/winpr/libwinpr/clipboard/synthetic.c +++ b/winpr/libwinpr/clipboard/synthetic.c @@ -653,7 +653,10 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form /* Check the BOM (Byte Order Mark) */ if ((pSrcData.cpb[0] == 0xFE) && (pSrcData.cpb[1] == 0xFF)) - ByteSwapUnicode(pSrcData.pv, (SrcSize / 2)); + { + if (!ByteSwapUnicode(pSrcData.pv, (SrcSize / 2))) + goto fail; + } /* Check if we have WCHAR, convert to UTF-8 */ if ((pSrcData.cpb[0] == 0xFF) && (pSrcData.cpb[1] == 0xFE)) diff --git a/winpr/libwinpr/clipboard/synthetic_file.c b/winpr/libwinpr/clipboard/synthetic_file.c index a9214f749..502fa47d1 100644 --- a/winpr/libwinpr/clipboard/synthetic_file.c +++ b/winpr/libwinpr/clipboard/synthetic_file.c @@ -104,7 +104,8 @@ static struct synthetic_file* make_synthetic_file(const WCHAR* local_name, const { const size_t len = _wcslen(file->remote_name); - PathCchConvertStyleW(file->remote_name, len, PATH_STYLE_WINDOWS); + if (S_OK != PathCchConvertStyleW(file->remote_name, len, PATH_STYLE_WINDOWS)) + goto fail; } file->dwFileAttributes = fd.dwFileAttributes; diff --git a/winpr/libwinpr/utils/collections/MessagePipe.c b/winpr/libwinpr/utils/collections/MessagePipe.c index 0266f6e3a..62ef6b01f 100644 --- a/winpr/libwinpr/utils/collections/MessagePipe.c +++ b/winpr/libwinpr/utils/collections/MessagePipe.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -34,6 +35,7 @@ void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode) { + WINPR_ASSERT(pipe); MessageQueue_PostQuit(pipe->In, nExitCode); MessageQueue_PostQuit(pipe->Out, nExitCode); } @@ -44,27 +46,23 @@ void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode) wMessagePipe* MessagePipe_New(void) { - wMessagePipe* pipe = nullptr; - - pipe = (wMessagePipe*)malloc(sizeof(wMessagePipe)); + wMessagePipe* pipe = (wMessagePipe*)calloc(1, sizeof(wMessagePipe)); if (!pipe) return nullptr; pipe->In = MessageQueue_New(nullptr); if (!pipe->In) - goto error_in; + goto fail; pipe->Out = MessageQueue_New(nullptr); if (!pipe->Out) - goto error_out; + goto fail; return pipe; -error_out: - MessageQueue_Free(pipe->In); -error_in: - free(pipe); +fail: + MessagePipe_Free(pipe); return nullptr; }