From b96c30939552dec7b6b935b5a9c7a860b45d578b Mon Sep 17 00:00:00 2001 From: Tom Cosgrove Date: Fri, 10 Feb 2023 12:52:13 +0000 Subject: [PATCH] Don't use lstrlenW() on Windows The lstrlenW() function isn't available to UWP apps, and isn't necessary, since when given -1, WideCharToMultiByte() will process the terminating null character itself (and the length returned by the function includes this character). Resolves #2994 Signed-off-by: Tom Cosgrove --- library/x509_crt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/x509_crt.c b/library/x509_crt.c index ecb903f4bb..cf62532f28 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -1449,8 +1449,8 @@ int mbedtls_x509_crt_parse_path(mbedtls_x509_crt *chain, const char *path) } w_ret = WideCharToMultiByte(CP_ACP, 0, file_data.cFileName, - lstrlenW(file_data.cFileName), - p, (int) len - 1, + -1, + p, (int) len, NULL, NULL); if (w_ret == 0) { ret = MBEDTLS_ERR_X509_FILE_IO_ERROR;