From 90b3510f1989cad606f8a5034fa8b5ddada0ea69 Mon Sep 17 00:00:00 2001 From: Sir Walrus Date: Wed, 22 May 2024 22:17:36 +0200 Subject: [PATCH] fix #74 --- flips.cpp | 14 ++++++++------ flips.h | 8 ++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/flips.cpp b/flips.cpp index e649253..99e360b 100644 --- a/flips.cpp +++ b/flips.cpp @@ -478,14 +478,15 @@ LPWSTR config::flatten() } LPWSTR ret = (LPWSTR)malloc((len+1)*sizeof(WCHAR)); + LPWSTR end = ret + len+1; LPWSTR at = ret; - at += wsprintf(at, TEXT("%s"), header); + at += swprintf(at, end-at, TEXT("%s"), header); for (size_t i=0;inumentries;i++) { if (this->values[i]!=NULL) { - at += wsprintf(at, TEXT("%s=%s\n"), this->names[i], this->values[i]); + at += swprintf(at, end-at, TEXT("%s=%s\n"), this->names[i], this->values[i]); } } @@ -522,7 +523,7 @@ config cfg; static LPWSTR EmuGetKey(LPCWSTR filename) { static WCHAR ret[64]; - wsprintf(ret, TEXT("emu%s"), GetExtension(filename)); + swprintf(ret, 64, TEXT("emu%s"), GetExtension(filename)); return ret; } @@ -561,9 +562,10 @@ static void CfgSumName(WCHAR* out, int type, const void* sum) { const uint8_t* sum8 = (uint8_t*)sum; wcscpy(out, checkmap_typenames[type]); + WCHAR* bufend = out + CfgSumNameMaxLen; WCHAR* end = out + wcslen(checkmap_typenames[type]); for (int i=0;i