From dc077eed78b403d83775aa6491f167581ab6768e Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 29 Nov 2022 22:57:49 +0100 Subject: [PATCH] [utils] fix smartcard string list conversion --- libfreerdp/utils/smartcard_pack.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libfreerdp/utils/smartcard_pack.c b/libfreerdp/utils/smartcard_pack.c index 27ceffe22..712d2ad38 100644 --- a/libfreerdp/utils/smartcard_pack.c +++ b/libfreerdp/utils/smartcard_pack.c @@ -352,10 +352,15 @@ static char* smartcard_convert_string_list(const void* in, size_t bytes, BOOL un if (!mszA) return NULL; CopyMemory(mszA, string.sz, bytes - 1); - length = bytes - 1; + length = bytes; } - for (index = 0; index < length; index++) + if (length < 1) + { + free(mszA); + return NULL; + } + for (index = 0; index < length - 1; index++) { if (mszA[index] == '\0') mszA[index] = ',';