From 94b35cb4f7d7bc272519c1a018c87d9ddbb897a4 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Wed, 13 Dec 2017 16:57:53 +0100 Subject: [PATCH] fix channel/smartcard: leak in Connect[AW] smartcard_Connect[AW] leaked the reader buffer in error case. --- .../smartcard/client/smartcard_operations.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index cea58e971..d0ed44f4d 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -767,17 +767,20 @@ static LONG smartcard_ConnectA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA if (status) { WLog_ERR(TAG, "SCardConnectA failed with error %"PRId32"", status); - return status; + goto out_fail; } if ((status = smartcard_pack_connect_return(smartcard, irp->output, &ret))) { WLog_ERR(TAG, "smartcard_pack_connect_return failed with error %"PRId32"", status); - return status; + goto out_fail; } + status = ret.ReturnCode; + +out_fail: free(call->szReader); - return ret.ReturnCode; + return status; } static LONG smartcard_ConnectW_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERATION* operation) @@ -823,17 +826,20 @@ static LONG smartcard_ConnectW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERA if (status) { WLog_ERR(TAG, "SCardConnectW failed with error %"PRId32"", status); - return status; + goto out_fail; } if ((status = smartcard_pack_connect_return(smartcard, irp->output, &ret))) { WLog_ERR(TAG, "smartcard_pack_connect_return failed with error %"PRId32"", status); - return status; + goto out_fail; } + status = ret.ReturnCode; + +out_fail: free(call->szReader); - return ret.ReturnCode; + return status; } static LONG smartcard_Reconnect_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERATION* operation)