From 9af563d4d193d5e73b35ff5d749d45213c1dbf16 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 3 Jul 2023 20:03:13 +0200 Subject: [PATCH] [smartcard] fix message queuing the queye key must not be 0 --- channels/smartcard/client/smartcard_main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c index 890a6d0f6..2bb67300c 100644 --- a/channels/smartcard/client/smartcard_main.c +++ b/channels/smartcard/client/smartcard_main.c @@ -329,14 +329,12 @@ static UINT smartcard_init(DEVICE* device) */ UINT smartcard_complete_irp(SMARTCARD_DEVICE* smartcard, IRP* irp, BOOL* handled) { - void* key; - WINPR_ASSERT(smartcard); WINPR_ASSERT(irp); WINPR_ASSERT(handled); - key = (void*)(size_t)irp->CompletionId; - ListDictionary_Remove(smartcard->rgOutstandingMessages, key); + uintptr_t key = (uintptr_t)irp->CompletionId + 1; + ListDictionary_Remove(smartcard->rgOutstandingMessages, (void*)key); WINPR_ASSERT(irp->Complete); *handled = TRUE; @@ -355,7 +353,6 @@ UINT smartcard_complete_irp(SMARTCARD_DEVICE* smartcard, IRP* irp, BOOL* handled */ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp, BOOL* handled) { - void* key; LONG status; BOOL asyncIrp = FALSE; SMARTCARD_CONTEXT* pContext = NULL; @@ -365,9 +362,9 @@ static UINT smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp, BOOL* h WINPR_ASSERT(irp); WINPR_ASSERT(irp->Complete); - key = (void*)(size_t)irp->CompletionId; + uintptr_t key = (uintptr_t)irp->CompletionId + 1; - if (!ListDictionary_Add(smartcard->rgOutstandingMessages, key, irp)) + if (!ListDictionary_Add(smartcard->rgOutstandingMessages, (void*)key, irp)) { WLog_ERR(TAG, "ListDictionary_Add failed!"); return ERROR_INTERNAL_ERROR;