From c0785aa1d4b6d988f175ca5732641e6ae2b10cc7 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 17 Jul 2023 14:28:45 +0200 Subject: Windows: Fix buffer overrun caused by bug in UpperCaseCopy function --- src/Common/Dlgcode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index df5d6355..2cf61415 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -1584,11 +1584,11 @@ void LowerCaseCopy (wchar_t *lpszDest, const wchar_t *lpszSource) void UpperCaseCopy (wchar_t *lpszDest, size_t cbDest, const wchar_t *lpszSource) { - if (lpszDest && cbDest) + if (lpszDest && (cbDest >= 2)) { size_t i = wcslen (lpszSource); - if (i >= cbDest) - i = cbDest - 1; + if (i >= (cbDest/2)) + i = (cbDest/2) - 1; lpszDest[i] = 0; i++; -- cgit v1.2.3