From e7edfbbf2204641ba08d0ae5e0d085e5f913f2d2 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 5 Jan 2009 18:16:44 +0000 Subject: [PATCH 1/1] windows-license-smgl2rtf-20090105 LICENSE MIT Ensure that the input string is nul terminated and then instruct WideCharToMultiByte to compute the length itself instead of passing in a value that is very likely to be wrong. --- src/WINNT/license/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/WINNT/license/main.cpp b/src/WINNT/license/main.cpp index be65a89..6f34969 100644 --- a/src/WINNT/license/main.cpp +++ b/src/WINNT/license/main.cpp @@ -216,8 +216,8 @@ BOOL TranslateFile (LPTSTR psz) DWORD cbSource; if ((cbSource = GetFileSize (hFile, NULL)) != 0) { - LPTSTR abSource = (LPTSTR)malloc(cbSource + 1); - memset(abSource, 0x00, cbSource + 1); + LPTSTR abSource = (LPTSTR)malloc(cbSource + 4); + memset(abSource, 0x00, cbSource + 4); DWORD dwRead; if (!ReadFile (hFile, abSource, cbSource, &dwRead, NULL) || cbSource != dwRead) @@ -232,7 +232,7 @@ BOOL TranslateFile (LPTSTR psz) memset (abTarget, 0x00, cbTarget); BOOL fDefault = FALSE; - WideCharToMultiByte (g::CodePage, 0, (LPCWSTR)abSource, cbSource, abTarget, cbTarget, TEXT(" "), &fDefault); + WideCharToMultiByte (g::CodePage, 0, (LPCWSTR)abSource, -1, abTarget, cbTarget, TEXT(" "), &fDefault); rc = FormatFile (psz, abTarget); -- 1.9.4