From 6c01433f6abd9b315b1bedebe8f90674b7cf05b3 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 27 Jul 2023 10:23:09 +0200 Subject: [PATCH] [core,smartcardlogon] fix warnings --- libfreerdp/core/smartcardlogon.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libfreerdp/core/smartcardlogon.c b/libfreerdp/core/smartcardlogon.c index b81976220..f5fc38601 100644 --- a/libfreerdp/core/smartcardlogon.c +++ b/libfreerdp/core/smartcardlogon.c @@ -894,12 +894,19 @@ BOOL smartcard_getCert(const rdpContext* context, SmartcardCertInfo** cert, BOOL return FALSE; } + if (count > UINT32_MAX) + { + WLog_ERR(TAG, "smartcard certificate count %" PRIuz " exceeds UINT32_MAX", count); + return FALSE; + } + if (count > 1) { - DWORD index; + DWORD index = 0; if (!instance->ChooseSmartcard || - !instance->ChooseSmartcard(context->instance, cert_list, count, &index, gateway)) + !instance->ChooseSmartcard(context->instance, cert_list, (UINT32)count, &index, + gateway)) { WLog_ERR(TAG, "more than one suitable smartcard certificate was found"); smartcardCertList_Free(cert_list, count);