From 962c5c3ef0477dffba48ae276d64f0da927d5691 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 28 Apr 2022 10:49:42 +0200 Subject: [PATCH] Fixed dead store warnings --- channels/ainput/server/ainput_main.c | 3 +- channels/disp/server/disp_main.c | 2 ++ channels/rdpgfx/client/rdpgfx_main.c | 2 ++ channels/rdpsnd/client/rdpsnd_main.c | 6 ++++ channels/urbdrc/client/urbdrc_main.c | 1 + client/X11/xf_cliprdr.c | 3 -- client/X11/xf_event.c | 10 ++---- client/X11/xf_keyboard.c | 10 +++--- client/X11/xf_monitor.c | 1 - libfreerdp/codec/dsp.c | 13 +++---- libfreerdp/common/addin.c | 8 +++-- libfreerdp/common/settings.c | 1 - libfreerdp/core/gateway/tsg.c | 4 +++ libfreerdp/core/info.c | 2 +- libfreerdp/core/nego.c | 3 -- libfreerdp/core/tscredentials.c | 1 - libfreerdp/crypto/tls.c | 3 +- libfreerdp/gdi/gfx.c | 5 ++- libfreerdp/locale/keyboard.c | 7 ++++ rdtk/librdtk/rdtk_nine_patch.c | 2 ++ winpr/libwinpr/clipboard/posix.c | 34 ++++++++----------- winpr/libwinpr/smartcard/smartcard_pcsc.c | 4 --- winpr/libwinpr/sspi/Kerberos/kerberos.c | 2 ++ winpr/libwinpr/sspi/NTLM/ntlm.c | 2 ++ .../libwinpr/sspi/Schannel/schannel_openssl.c | 15 ++++++-- 25 files changed, 83 insertions(+), 61 deletions(-) diff --git a/channels/ainput/server/ainput_main.c b/channels/ainput/server/ainput_main.c index 8f7ad2c3b..6aaf87fe1 100644 --- a/channels/ainput/server/ainput_main.c +++ b/channels/ainput/server/ainput_main.c @@ -235,7 +235,7 @@ static DWORD WINAPI ainput_server_thread_func(LPVOID arg) case WAIT_OBJECT_0 + 1: case WAIT_OBJECT_0: error = ainput_server_context_poll_int(&ainput->context); - + break; case WAIT_FAILED: default: error = ERROR_INTERNAL_ERROR; @@ -250,6 +250,7 @@ static DWORD WINAPI ainput_server_thread_func(LPVOID arg) case WAIT_OBJECT_0 + 1: case WAIT_OBJECT_0: error = ainput_server_context_poll_int(&ainput->context); + break; case WAIT_FAILED: default: diff --git a/channels/disp/server/disp_main.c b/channels/disp/server/disp_main.c index 408dd8aa7..5232df640 100644 --- a/channels/disp/server/disp_main.c +++ b/channels/disp/server/disp_main.c @@ -446,6 +446,7 @@ static UINT disp_server_open(DispServerContext* context) { WLog_ERR(TAG, "CreateEvent failed!"); rc = ERROR_INTERNAL_ERROR; + goto out_close; } if (!(priv->thread = @@ -455,6 +456,7 @@ static UINT disp_server_open(DispServerContext* context) CloseHandle(priv->stopEvent); priv->stopEvent = NULL; rc = ERROR_INTERNAL_ERROR; + goto out_close; } } diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 28db70fc2..345a5e275 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -588,6 +588,7 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wS "RecvResetGraphicsPdu: width: %" PRIu32 " height: %" PRIu32 " count: %" PRIu32 "", pdu.width, pdu.height, pdu.monitorCount); +#if defined(WITH_DEBUG_RDPGFX) for (index = 0; index < pdu.monitorCount; index++) { monitor = &(pdu.monitorDefArray[index]); @@ -596,6 +597,7 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wS " bottom:%" PRIi32 " flags:0x%" PRIx32 "", monitor->left, monitor->top, monitor->right, monitor->bottom, monitor->flags); } +#endif if (context) { diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 06beaa1d2..ec4a60fdc 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -1665,6 +1665,12 @@ static UINT rdpsnd_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana rdpsnd->listener_callback->channel_mgr = pChannelMgr; status = pChannelMgr->CreateListener(pChannelMgr, RDPSND_DVC_CHANNEL_NAME, 0, &rdpsnd->listener_callback->iface, &(rdpsnd->listener)); + if (status != CHANNEL_RC_OK) + { + WLog_ERR(TAG, "%s CreateListener failed!", rdpsnd_is_dyn_str(TRUE)); + return status; + } + rdpsnd->listener->pInterface = rdpsnd->iface.pInterface; status = rdpsnd_virtual_channel_event_initialized(rdpsnd); diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index 0d69f09cf..8a5bcf9bc 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -595,6 +595,7 @@ static UINT urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback default: error = urbdrc_process_udev_data_transfer(callback, urbdrc, udevman, data); + WLog_DBG(TAG, "urbdrc_process_udev_data_transfer returned 0x%08" PRIx32, error); error = ERROR_SUCCESS; /* Ignore errors, the device may have been unplugged. */ break; } diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 25679f1af..143e51c83 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -2963,7 +2963,6 @@ xfClipboard* xf_clipboard_new(xfContext* xfc) clientFormat = &clipboard->clientFormats[n++]; } - if (ClipboardGetFormatId(clipboard->system, "x-special/mate-copied-files")) { clipboard->file_formats_registered = TRUE; @@ -2973,8 +2972,6 @@ xfClipboard* xf_clipboard_new(xfContext* xfc) if (!clientFormat->formatName) goto error; - - clientFormat = &clipboard->clientFormats[n++]; } clipboard->numClientFormats = n; diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index d645d91a6..42a970480 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -308,17 +308,14 @@ void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y) void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y) { - rdpSettings* settings; - if (!xfc || !xfc->common.context.settings || !y || !x) return; - settings = xfc->common.context.settings; if (!xfc->remote_app) { #ifdef WITH_XRENDER - + rdpSettings* settings = xfc->common.context.settings; if (xf_picture_transform_required(xfc)) { double xScalingFactor = settings->DesktopWidth / (double)xfc->scaledWidth; @@ -332,6 +329,7 @@ void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y) CLAMP_COORDINATES(*x, *y); } + static BOOL xf_event_Expose(xfContext* xfc, const XExposeEvent* event, BOOL app) { int x, y; @@ -899,8 +897,6 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, { unsigned long i; BOOL status; - BOOL maxVert = FALSE; - BOOL maxHorz = FALSE; BOOL minimized = FALSE; BOOL minimizedChanged = FALSE; unsigned long nitems; @@ -933,7 +929,6 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, if ((Atom)((UINT16**)prop)[i] == XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False)) { - maxVert = TRUE; if (appWindow) appWindow->maxVert = TRUE; } @@ -941,7 +936,6 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, if ((Atom)((UINT16**)prop)[i] == XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False)) { - maxHorz = TRUE; if (appWindow) appWindow->maxHorz = TRUE; } diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index a8264bf79..c5f7f9800 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -248,11 +248,9 @@ void xf_keyboard_send_key(xfContext* xfc, BOOL down, const XKeyEvent* event) } else { - BOOL rc; if (freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_UnicodeInput)) { wchar_t buffer[32] = { 0 }; - int rc = 0; int xwc = -1; switch (rdp_scancode) @@ -280,16 +278,16 @@ void xf_keyboard_send_key(xfContext* xfc, BOOL down, const XKeyEvent* event) if (rdp_scancode == RDP_SCANCODE_UNKNOWN) WLog_ERR(TAG, "Unknown key with X keycode 0x%02" PRIx8 "", event->keycode); else - rc = freerdp_input_send_keyboard_event_ex(input, down, rdp_scancode); + freerdp_input_send_keyboard_event_ex(input, down, rdp_scancode); } else - rc = freerdp_input_send_unicode_keyboard_event(input, down ? KBD_FLAGS_RELEASE : 0, - buffer[0]); + freerdp_input_send_unicode_keyboard_event(input, down ? KBD_FLAGS_RELEASE : 0, + buffer[0]); } else if (rdp_scancode == RDP_SCANCODE_UNKNOWN) WLog_ERR(TAG, "Unknown key with X keycode 0x%02" PRIx8 "", event->keycode); else - rc = freerdp_input_send_keyboard_event_ex(input, down, rdp_scancode); + freerdp_input_send_keyboard_event_ex(input, down, rdp_scancode); if ((rdp_scancode == RDP_SCANCODE_CAPSLOCK) && (down == FALSE)) { diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index f385adca9..d13cf0dbd 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -532,7 +532,6 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) settings->MonitorDefArray[j].is_primary = TRUE; settings->MonitorLocalShiftX = settings->MonitorDefArray[j].x; settings->MonitorLocalShiftY = settings->MonitorDefArray[j].y; - primaryMonitorFound = TRUE; } else { diff --git a/libfreerdp/codec/dsp.c b/libfreerdp/codec/dsp.c index d790b2146..7d9372ded 100644 --- a/libfreerdp/codec/dsp.c +++ b/libfreerdp/codec/dsp.c @@ -212,9 +212,10 @@ static BOOL freerdp_dsp_resample(FREERDP_DSP_CONTEXT* context, const BYTE* src, size_t sframes, rframes; size_t rsize; size_t sbytes, rbytes; -#endif + size_t dstChannels; + size_t srcChannels; size_t srcBytesPerFrame, dstBytesPerFrame; - size_t srcChannels, dstChannels; +#endif AUDIO_FORMAT format; if (srcFormat->wFormatTag != WAVE_FORMAT_PCM) @@ -225,10 +226,6 @@ static BOOL freerdp_dsp_resample(FREERDP_DSP_CONTEXT* context, const BYTE* src, return FALSE; } - srcChannels = srcFormat->nChannels; - dstChannels = context->format.nChannels; - srcBytesPerFrame = (srcFormat->wBitsPerSample > 8) ? 2 : 1; - dstBytesPerFrame = (context->format.wBitsPerSample > 8) ? 2 : 1; /* We want to ignore differences of source and destination format. */ format = *srcFormat; format.wFormatTag = WAVE_FORMAT_UNKNOWN; @@ -242,6 +239,10 @@ static BOOL freerdp_dsp_resample(FREERDP_DSP_CONTEXT* context, const BYTE* src, } #if defined(WITH_SOXR) + srcBytesPerFrame = (srcFormat->wBitsPerSample > 8) ? 2 : 1; + dstBytesPerFrame = (context->format.wBitsPerSample > 8) ? 2 : 1; + srcChannels = srcFormat->nChannels; + dstChannels = context->format.nChannels; sbytes = srcChannels * srcBytesPerFrame; sframes = size / sbytes; rbytes = dstBytesPerFrame * dstChannels; diff --git a/libfreerdp/common/addin.c b/libfreerdp/common/addin.c index 64d94888b..02e4e2dd2 100644 --- a/libfreerdp/common/addin.c +++ b/libfreerdp/common/addin.c @@ -300,7 +300,7 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LP LPCSTR pszExtension = PathGetSharedLibraryExtensionA(0); LPCSTR pszPrefix = FREERDP_SHARED_LIBRARY_PREFIX; LPSTR tmp; - int rc; + int rc = 0; if (pszPrefix) cchFileName += strnlen(pszPrefix, MAX_PATH); @@ -309,10 +309,14 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LP tmp = calloc(cchFileName, sizeof(CHAR)); if (tmp) rc = sprintf_s(tmp, cchFileName, "%s%s.%s", pszPrefix, pszFileName, pszExtension); + free(pszFileName); pszFileName = tmp; - if (!pszFileName) + if (!pszFileName || (rc < 0)) + { + free(pszFileName); return NULL; + } } if (pszSubsystem) diff --git a/libfreerdp/common/settings.c b/libfreerdp/common/settings.c index 36023aaa5..72ce15e7e 100644 --- a/libfreerdp/common/settings.c +++ b/libfreerdp/common/settings.c @@ -353,7 +353,6 @@ RDPDR_DEVICE* freerdp_device_new(UINT32 Type, size_t count, const char* args[]) if (!device.serial->Permissive) goto fail; } - size = sizeof(RDPDR_SERIAL); break; case RDPDR_DTYP_PARALLEL: if (count > 1) diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index b996e363d..41c7a2c2c 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -1673,6 +1673,8 @@ static BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) packetStringMessage.isDisplayMandatory != 0, packetStringMessage.isConsentMandatory != 0, packetStringMessage.msgBytes, packetStringMessage.msgBuffer); + if (!rc) + goto fail; } break; @@ -1694,6 +1696,8 @@ static BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) packetStringMessage.isDisplayMandatory != 0, packetStringMessage.isConsentMandatory != 0, packetStringMessage.msgBytes, packetStringMessage.msgBuffer); + if (!rc) + goto fail; } break; diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index 81fe1456a..0157e0457 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -911,7 +911,7 @@ fail: if (settings->RdpVersion >= RDP_VERSION_5_PLUS) ret = rdp_write_extended_info_packet(rdp, s); /* extraInfo */ - return TRUE; + return ret; } /** diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 48a57d1e2..7b3a29a44 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -1239,8 +1239,6 @@ BOOL nego_send_negotiation_response(rdpNego* nego) settings = context->settings; WINPR_ASSERT(settings); - status = TRUE; - s = Stream_New(NULL, 512); if (!s) @@ -1262,7 +1260,6 @@ BOOL nego_send_negotiation_response(rdpNego* nego) Stream_Write_UINT16(s, 8); /* RDP_NEG_DATA length (8) */ Stream_Write_UINT32(s, errorCode); length += 8; - status = FALSE; } else { diff --git a/libfreerdp/core/tscredentials.c b/libfreerdp/core/tscredentials.c index ec0b26432..ac3587248 100644 --- a/libfreerdp/core/tscredentials.c +++ b/libfreerdp/core/tscredentials.c @@ -846,7 +846,6 @@ BOOL ber_read_nla_TSRemoteGuardPackageCred_array(wStream* s, TSRemoteGuardPackag } retItems = tmpRet; - retItems = tmpRet; memcpy(&retItems[ret], item, sizeof(*item)); free(item); ret++; diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index e2742d149..39e8b9e04 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -313,6 +313,8 @@ static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr) case BIO_CTRL_FLUSH: BIO_clear_retry_flags(bio); status = BIO_ctrl(ssl_wbio, cmd, num, ptr); + if (status != 1) + WLog_DBG(TAG, "BIO_ctrl returned %d", status); BIO_copy_next_retry(bio); status = 1; break; @@ -377,7 +379,6 @@ static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr) { tls->ssl = (SSL*)ptr; ssl_rbio = SSL_get_rbio(tls->ssl); - ssl_wbio = SSL_get_wbio(tls->ssl); } if (ssl_rbio) diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index b85999552..ea9689b06 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -1147,6 +1147,7 @@ static UINT gdi_DeleteSurface(RdpgfxClientContext* context, const RDPGFX_DELETE_SURFACE_PDU* deleteSurface) { UINT rc = ERROR_INTERNAL_ERROR; + UINT res = ERROR_INTERNAL_ERROR; rdpCodecs* codecs = NULL; gdiGfxSurface* surface = NULL; EnterCriticalSection(&context->mux); @@ -1167,7 +1168,9 @@ static UINT gdi_DeleteSurface(RdpgfxClientContext* context, free(surface); } - rc = context->SetSurfaceData(context, deleteSurface->surfaceId, NULL); + res = context->SetSurfaceData(context, deleteSurface->surfaceId, NULL); + if (res) + rc = res; if (codecs && codecs->progressive) progressive_delete_surface_context(codecs->progressive, deleteSurface->surfaceId); diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index 19bb1183c..5746db455 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -28,12 +28,16 @@ #include #include +#include + #include "liblocale.h" #if defined(__MACOSX__) #include "keyboard_apple.h" #endif +#define TAG FREERDP_TAG("locale.keyboard") + #ifdef WITH_X11 #include "keyboard_x11.h" @@ -314,6 +318,9 @@ DWORD freerdp_keyboard_init(DWORD keyboardLayoutId) #endif + if (status < 0) + WLog_DBG(TAG, "Failed to initialize keyboard layout, trying autodetection"); + freerdp_detect_keyboard(&keyboardLayoutId); ZeroMemory(VIRTUAL_SCANCODE_TO_X11_KEYCODE, sizeof(VIRTUAL_SCANCODE_TO_X11_KEYCODE)); diff --git a/rdtk/librdtk/rdtk_nine_patch.c b/rdtk/librdtk/rdtk_nine_patch.c index 04ccfe329..d3d341ea4 100644 --- a/rdtk/librdtk/rdtk_nine_patch.c +++ b/rdtk/librdtk/rdtk_nine_patch.c @@ -86,6 +86,8 @@ int rdtk_nine_patch_draw(rdtkSurface* surface, int nXDst, int nYDst, int nWidth, if (nHeight < ninePatch->height) nHeight = ninePatch->height; + WINPR_UNUSED(nHeight); + scaleWidth = nWidth - (ninePatch->width - ninePatch->scaleWidth); nSrcStep = ninePatch->scanline; pSrcData = ninePatch->data; diff --git a/winpr/libwinpr/clipboard/posix.c b/winpr/libwinpr/clipboard/posix.c index 0d1c7936c..8fe7bf867 100644 --- a/winpr/libwinpr/clipboard/posix.c +++ b/winpr/libwinpr/clipboard/posix.c @@ -687,6 +687,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32 for (x = 0; x < count; x++) { + BOOL fail = TRUE; if (_wcschr(descriptors[x].cFileName, L'\\') != NULL) { continue; @@ -698,14 +699,14 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32 const char* stop_at = NULL; const char* previous_at = NULL; rc = ConvertFromUnicode(CP_UTF8, 0, cur->cFileName, (int)curLen, &curName, 0, NULL, NULL); + if (rc < 0) + goto loop_fail; rc = _snprintf(&dst[pos], alloc - pos, "%s%s/", lineprefix, clipboard->delegate.basePath); if (rc < 0) - { - free(dst); - return NULL; - } + goto loop_fail; + pos += (size_t)rc; previous_at = curName; @@ -713,34 +714,27 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32 { char* tmp = strndup(previous_at, stop_at - previous_at); if (!tmp) - { - free(dst); - free(curName); - return NULL; - } + goto loop_fail; + rc = _snprintf(&dst[pos], stop_at - previous_at + 1, "%s", tmp); free(tmp); if (rc < 0) - { - free(dst); - free(curName); - return NULL; - } + goto loop_fail; + pos += (size_t)rc; rc = _snprintf(&dst[pos], 4, "%%%x", *stop_at); if (rc < 0) - { - free(dst); - free(curName); - return NULL; - } + goto loop_fail; + pos += (size_t)rc; previous_at = stop_at + 1; } rc = _snprintf(&dst[pos], alloc - pos, "%s%s", previous_at, lineending); - if (rc < 0) + fail = FALSE; + loop_fail: + if ((rc < 0) || fail) { free(dst); free(curName); diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c index e447d693f..463b264bc 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.c +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c @@ -2269,9 +2269,7 @@ static LONG WINAPI PCSC_SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPC DWORD cbInBufferSize, LPVOID lpOutBuffer, DWORD cbOutBufferSize, LPDWORD lpBytesReturned) { - DWORD IoCtlMethod = 0; DWORD IoCtlFunction = 0; - DWORD IoCtlAccess = 0; DWORD IoCtlDeviceType = 0; BOOL getFeatureRequest = FALSE; PCSC_LONG status = SCARD_S_SUCCESS; @@ -2300,9 +2298,7 @@ static LONG WINAPI PCSC_SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPC * Converting Windows Feature Request IOCTL code to the pcsc-lite control code: * http://musclecard.996296.n3.nabble.com/Converting-Windows-Feature-Request-IOCTL-code-to-the-pcsc-lite-control-code-td4906.html */ - IoCtlMethod = METHOD_FROM_CTL_CODE(dwControlCode); IoCtlFunction = FUNCTION_FROM_CTL_CODE(dwControlCode); - IoCtlAccess = ACCESS_FROM_CTL_CODE(dwControlCode); IoCtlDeviceType = DEVICE_TYPE_FROM_CTL_CODE(dwControlCode); if (dwControlCode == IOCTL_SMARTCARD_GET_FEATURE_REQUEST) diff --git a/winpr/libwinpr/sspi/Kerberos/kerberos.c b/winpr/libwinpr/sspi/Kerberos/kerberos.c index a87b1c0bc..fe5bc0c85 100644 --- a/winpr/libwinpr/sspi/Kerberos/kerberos.c +++ b/winpr/libwinpr/sspi/Kerberos/kerberos.c @@ -659,8 +659,10 @@ static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA( cnv.cpv = KRB_PACKAGE_NAME; sspi_SecureHandleSetUpperPointer(phNewContext, cnv.pv); } +#if defined(WITH_GSSAPI) else credentials = context->credentials; +#endif if (pInput) { diff --git a/winpr/libwinpr/sspi/NTLM/ntlm.c b/winpr/libwinpr/sspi/NTLM/ntlm.c index 73c8533ba..1c2cdf74c 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm.c @@ -227,6 +227,8 @@ static NTLM_CONTEXT* ntlm_ContextNew(void) status = RegQueryValueExA(hKey, "WorkstationName", NULL, &dwType, (BYTE*)workstation, &dwSize); + if (status != ERROR_SUCCESS) + WLog_WARN(TAG, "[%s]: Key ''WorkstationName' not found", __FUNCTION__); workstation[dwSize] = '\0'; if (ntlm_SetContextWorkstation(context, workstation) < 0) diff --git a/winpr/libwinpr/sspi/Schannel/schannel_openssl.c b/winpr/libwinpr/sspi/Schannel/schannel_openssl.c index c6dc926f5..2889cd148 100644 --- a/winpr/libwinpr/sspi/Schannel/schannel_openssl.c +++ b/winpr/libwinpr/sspi/Schannel/schannel_openssl.c @@ -355,6 +355,8 @@ SECURITY_STATUS schannel_openssl_client_process_tokens(SCHANNEL_OPENSSL* context return SEC_E_INVALID_TOKEN; status = BIO_write(context->bioRead, pBuffer->pvBuffer, pBuffer->cbBuffer); + if (status < 0) + return SEC_E_INVALID_TOKEN; } status = SSL_connect(context->ssl); @@ -416,18 +418,26 @@ SECURITY_STATUS schannel_openssl_server_process_tokens(SCHANNEL_OPENSSL* context return SEC_E_INVALID_TOKEN; status = BIO_write(context->bioRead, pBuffer->pvBuffer, pBuffer->cbBuffer); - status = SSL_accept(context->ssl); + if (status >= 0) + status = SSL_accept(context->ssl); if (status < 0) { ssl_error = SSL_get_error(context->ssl, status); WLog_ERR(TAG, "SSL_accept error: %s", openssl_get_ssl_error_string(ssl_error)); + return SEC_E_INVALID_TOKEN; } if (status == 1) context->connected = TRUE; status = BIO_read(context->bioWrite, context->ReadBuffer, SCHANNEL_CB_MAX_TOKEN); + if (status < 0) + { + ssl_error = SSL_get_error(context->ssl, status); + WLog_ERR(TAG, "BIO_read: %s", openssl_get_ssl_error_string(ssl_error)); + return SEC_E_INVALID_TOKEN; + } if (pOutput->cBuffers < 1) return SEC_E_INVALID_TOKEN; @@ -516,7 +526,8 @@ SECURITY_STATUS schannel_openssl_decrypt_message(SCHANNEL_OPENSSL* context, PSec return SEC_E_INVALID_TOKEN; status = BIO_write(context->bioRead, pBuffer->pvBuffer, pBuffer->cbBuffer); - status = SSL_read(context->ssl, pBuffer->pvBuffer, pBuffer->cbBuffer); + if (status > 0) + status = SSL_read(context->ssl, pBuffer->pvBuffer, pBuffer->cbBuffer); if (status < 0) {