diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index 05f9752be..57c1da52d 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -1536,7 +1536,9 @@ static UINT rdpdr_server_receive_io_lock_control_request(RdpdrServerContext* con WLog_Print(context->priv->log, WLOG_WARN, "[MS-RDPEFS] 2.2.3.3.12 Server Drive Lock Control Request (DR_DRIVE_LOCK_REQ) " - "not implemented"); + "[Lock=0x%08" PRIx32 "]" + "not implemented", + Lock); WLog_Print(context->priv->log, WLOG_WARN, "TODO"); return CHANNEL_RC_OK; diff --git a/client/SDL/SDL2/dialogs/sdl_connection_dialog.cpp b/client/SDL/SDL2/dialogs/sdl_connection_dialog.cpp index c63673f8f..a6a278912 100644 --- a/client/SDL/SDL2/dialogs/sdl_connection_dialog.cpp +++ b/client/SDL/SDL2/dialogs/sdl_connection_dialog.cpp @@ -91,6 +91,8 @@ bool SDLConnectionDialog::showError(const char* fmt, ...) va_start(ap, fmt); auto rc = show(MSG_ERROR, fmt, ap); va_end(ap); + if (!rc) + return rc; return setTimer(); } diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp index cedb12867..e5791abc4 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp @@ -91,6 +91,8 @@ bool SDLConnectionDialog::showError(const char* fmt, ...) va_start(ap, fmt); auto rc = show(MSG_ERROR, fmt, ap); va_end(ap); + if (!rc) + return rc; return setTimer(); } diff --git a/client/common/client.c b/client/common/client.c index 55a6d9a34..6697dee06 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -1001,9 +1001,7 @@ static char* extract_authorization_code(char* url) end = strchr(p, '&'); if (end) - *end = 0; - else - end = strchr(p, '\0'); + *end = '\0'; return p; } diff --git a/libfreerdp/codec/dsp_ffmpeg.c b/libfreerdp/codec/dsp_ffmpeg.c index 2f1210173..c48383048 100644 --- a/libfreerdp/codec/dsp_ffmpeg.c +++ b/libfreerdp/codec/dsp_ffmpeg.c @@ -360,7 +360,8 @@ static BOOL ffmpeg_open_context(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context) context->buffered->format = context->resampled->format; context->buffered->nb_samples = context->context->frame_size; - if ((ret = av_frame_get_buffer(context->buffered, 1)) < 0) + ret = av_frame_get_buffer(context->buffered, 1); + if (ret < 0) goto fail; } diff --git a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c index 0bba985c3..b5191d01d 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c @@ -1065,6 +1065,8 @@ static BOOL test_encode_decode(const char* path) rc = progressive_compress(progressiveEnc, image->data, image->scanline * image->height, ColorFormat, image->width, image->height, image->scanline, NULL, &dstData, &dstSize); + if (rc < 0) + goto fail; // Progressive decode rc = progressive_create_surface_context(progressiveDec, 0, image->width, image->height); diff --git a/libfreerdp/gdi/graphics.c b/libfreerdp/gdi/graphics.c index 5c1409fc1..bcb9f9776 100644 --- a/libfreerdp/gdi/graphics.c +++ b/libfreerdp/gdi/graphics.c @@ -133,7 +133,6 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, const UINT32 DstWidth, UINT32 DstHeight, UINT32 bpp, UINT32 length, BOOL compressed, UINT32 codecId) { - int status = 0; UINT32 SrcSize = length; rdpGdi* gdi = context->gdi; UINT32 size = DstWidth * DstHeight; @@ -169,14 +168,12 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, const WLog_ERR(TAG, "rfx_process_message failed"); return FALSE; } - - status = 1; } else if (codecId == RDP_CODEC_ID_NSCODEC) { - status = nsc_process_message(context->codecs->nsc, 32, DstWidth, DstHeight, pSrcData, - SrcSize, bitmap->data, bitmap->format, 0, 0, 0, DstWidth, - DstHeight, FREERDP_FLIP_VERTICAL); + const int status = nsc_process_message( + context->codecs->nsc, 32, DstWidth, DstHeight, pSrcData, SrcSize, bitmap->data, + bitmap->format, 0, 0, 0, DstWidth, DstHeight, FREERDP_FLIP_VERTICAL); if (status < 1) { diff --git a/server/proxy/cli/freerdp_proxy.c b/server/proxy/cli/freerdp_proxy.c index 1ee25b8c9..4977f8d20 100644 --- a/server/proxy/cli/freerdp_proxy.c +++ b/server/proxy/cli/freerdp_proxy.c @@ -96,8 +96,6 @@ static WINPR_NORETURN(void buildconfig(const char* app)) int main(int argc, char* argv[]) { - proxyConfig* config = NULL; - char* config_path = "config.ini"; int status = -1; pf_server_register_signal_handlers(); @@ -110,31 +108,29 @@ int main(int argc, char* argv[]) if (argc < 2) usage(argv[0]); + const char* arg = argv[1]; + + if (_stricmp(arg, "-h") == 0) + usage(argv[0]); + else if (_stricmp(arg, "--help") == 0) + usage(argv[0]); + else if (_stricmp(arg, "--buildconfig") == 0) + buildconfig(argv[0]); + else if (_stricmp(arg, "--dump-config") == 0) { - const char* arg = argv[1]; - - if (_stricmp(arg, "-h") == 0) + if (argc <= 2) usage(argv[0]); - else if (_stricmp(arg, "--help") == 0) - usage(argv[0]); - else if (_stricmp(arg, "--buildconfig") == 0) - buildconfig(argv[0]); - else if (_stricmp(arg, "--dump-config") == 0) - { - if (argc <= 2) - usage(argv[0]); - pf_server_config_dump(argv[2]); - status = 0; - goto fail; - } - else if (_stricmp(arg, "-v") == 0) - version(argv[0]); - else if (_stricmp(arg, "--version") == 0) - version(argv[0]); - config_path = argv[1]; + pf_server_config_dump(argv[2]); + status = 0; + goto fail; } + else if (_stricmp(arg, "-v") == 0) + version(argv[0]); + else if (_stricmp(arg, "--version") == 0) + version(argv[0]); + const char* config_path = argv[1]; - config = pf_server_config_load_file(config_path); + proxyConfig* config = pf_server_config_load_file(config_path); if (!config) goto fail; diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedSList.c b/winpr/libwinpr/interlocked/test/TestInterlockedSList.c index 71ac8bcb1..09969f2ee 100644 --- a/winpr/libwinpr/interlocked/test/TestInterlockedSList.c +++ b/winpr/libwinpr/interlocked/test/TestInterlockedSList.c @@ -4,6 +4,8 @@ #include #include +#define ITEM_COUNT 23 + typedef struct { WINPR_SLIST_ENTRY ItemEntry; @@ -12,14 +14,14 @@ typedef struct int TestInterlockedSList(int argc, char* argv[]) { - ULONG Count = 0; - WINPR_PSLIST_ENTRY pFirstEntry = NULL; - WINPR_PSLIST_HEADER pListHead = NULL; + int rc = -1; + WINPR_UNUSED(argc); WINPR_UNUSED(argv); + /* Initialize the list header to a MEMORY_ALLOCATION_ALIGNMENT boundary. */ - pListHead = (WINPR_PSLIST_HEADER)winpr_aligned_malloc(sizeof(WINPR_SLIST_HEADER), - MEMORY_ALLOCATION_ALIGNMENT); + WINPR_PSLIST_HEADER pListHead = (WINPR_PSLIST_HEADER)winpr_aligned_malloc( + sizeof(WINPR_SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT); if (!pListHead) { @@ -30,7 +32,7 @@ int TestInterlockedSList(int argc, char* argv[]) InitializeSListHead(pListHead); /* Insert 10 items into the list. */ - for (Count = 1; Count <= 10; Count += 1) + for (ULONG Count = 0; Count < ITEM_COUNT; Count++) { PPROGRAM_ITEM pProgramItem = (PPROGRAM_ITEM)winpr_aligned_malloc(sizeof(PROGRAM_ITEM), MEMORY_ALLOCATION_ALIGNMENT); @@ -38,26 +40,32 @@ int TestInterlockedSList(int argc, char* argv[]) if (!pProgramItem) { printf("Memory allocation failed.\n"); - return -1; + goto fail; } - pProgramItem->Signature = Count; - pFirstEntry = InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry)); + pProgramItem->Signature = Count + 1UL; + WINPR_PSLIST_ENTRY pFirstEntry = + InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry)); + if (((Count == 0) && pFirstEntry) || ((Count != 0) && !pFirstEntry)) + { + printf("Error: List is empty.\n"); + winpr_aligned_free(pProgramItem); + goto fail; + } } /* Remove 10 items from the list and display the signature. */ - for (Count = 10; Count >= 1; Count -= 1) + for (ULONG Count = 0; Count < ITEM_COUNT; Count++) { - PPROGRAM_ITEM pProgramItem = NULL; WINPR_PSLIST_ENTRY pListEntry = InterlockedPopEntrySList(pListHead); if (!pListEntry) { printf("List is empty.\n"); - return -1; + goto fail; } - pProgramItem = (PPROGRAM_ITEM)pListEntry; + PPROGRAM_ITEM pProgramItem = (PPROGRAM_ITEM)pListEntry; printf("Signature is %" PRIu32 "\n", pProgramItem->Signature); /* @@ -71,15 +79,17 @@ int TestInterlockedSList(int argc, char* argv[]) } /* Flush the list and verify that the items are gone. */ - pFirstEntry = InterlockedPopEntrySList(pListHead); + WINPR_PSLIST_ENTRY pFirstEntry = InterlockedPopEntrySList(pListHead); if (pFirstEntry) { printf("Error: List is not empty.\n"); - return -1; + goto fail; } + rc = 0; +fail: winpr_aligned_free(pListHead); - return 0; + return rc; } diff --git a/winpr/libwinpr/sspi/NTLM/ntlm.c b/winpr/libwinpr/sspi/NTLM/ntlm.c index 4e4c98ee8..4864781ee 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm.c @@ -608,7 +608,6 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW( SSPI_CREDENTIALS* credentials = NULL; PSecBuffer input_buffer = NULL; PSecBuffer output_buffer = NULL; - PSecBuffer channel_bindings = NULL; /* behave like windows SSPIs that don't want empty context */ if (phContext && !phContext->dwLower && !phContext->dwUpper) @@ -619,7 +618,6 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW( if (pInput) { input_buffer = sspi_FindSecBuffer(pInput, SECBUFFER_TOKEN); - channel_bindings = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS); } if (!context) @@ -686,7 +684,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW( if (input_buffer->cbBuffer < 1) return SEC_E_INVALID_TOKEN; - channel_bindings = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS); + PSecBuffer channel_bindings = sspi_FindSecBuffer(pInput, SECBUFFER_CHANNEL_BINDINGS); if (channel_bindings) { diff --git a/winpr/libwinpr/sspi/test/TestNTLM.c b/winpr/libwinpr/sspi/test/TestNTLM.c index 8489d8ddf..87b8179d7 100644 --- a/winpr/libwinpr/sspi/test/TestNTLM.c +++ b/winpr/libwinpr/sspi/test/TestNTLM.c @@ -396,7 +396,6 @@ static int test_ntlm_server_authenticate(TEST_NTLM_SERVER* ntlm) ntlm->outputBuffer[0].BufferType = SECBUFFER_TOKEN; ntlm->outputBuffer[0].cbBuffer = ntlm->cbMaxToken; ntlm->outputBuffer[0].pvBuffer = malloc(ntlm->outputBuffer[0].cbBuffer); - BOOL hash_set = FALSE; if (!ntlm->outputBuffer[0].pvBuffer) return -1; @@ -406,7 +405,7 @@ static int test_ntlm_server_authenticate(TEST_NTLM_SERVER* ntlm) ntlm->fContextReq, SECURITY_NATIVE_DREP, &ntlm->context, &ntlm->outputBufferDesc, &ntlm->pfContextAttr, &ntlm->expiration); - if (!hash_set && status == SEC_I_CONTINUE_NEEDED) + if (status == SEC_I_CONTINUE_NEEDED) { SecPkgContext_AuthNtlmHash AuthNtlmHash = { 0 }; @@ -424,8 +423,6 @@ static int test_ntlm_server_authenticate(TEST_NTLM_SERVER* ntlm) status = ntlm->table->SetContextAttributes(&ntlm->context, SECPKG_ATTR_AUTH_NTLM_HASH, &AuthNtlmHash, sizeof(SecPkgContext_AuthNtlmHash)); - - hash_set = TRUE; } if ((status != SEC_E_OK) && (status != SEC_I_CONTINUE_NEEDED))