From b8bfaa926937d38ffa0f8a1fcf685312bfb038b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 19 Feb 2023 23:05:16 +0100 Subject: [PATCH] Fix buffer lengths in `swprintf` calls --- src/86box.c | 6 +++--- src/win/win_about.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/86box.c b/src/86box.c index 11d5c1ff8..f318bcfbc 100644 --- a/src/86box.c +++ b/src/86box.c @@ -853,7 +853,7 @@ pc_init_modules(void) /* Load the ROMs for the selected machine. */ if (!machine_available(machine)) { - swprintf(temp, sizeof(temp), plat_get_string(IDS_2063), machine_getname()); + swprintf(temp, sizeof_w(temp), plat_get_string(IDS_2063), machine_getname()); c = 0; machine = -1; while (machine_get_internal_name_ex(c) != NULL) { @@ -876,7 +876,7 @@ pc_init_modules(void) if (!video_card_available(gfxcard[0])) { memset(tempc, 0, sizeof(tempc)); device_get_name(video_card_getdevice(gfxcard[0]), 0, tempc); - swprintf(temp, sizeof(temp), plat_get_string(IDS_2064), tempc); + swprintf(temp, sizeof_w(temp), plat_get_string(IDS_2064), tempc); c = 0; while (video_get_internal_name(c) != NULL) { gfxcard[0] = -1; @@ -898,7 +898,7 @@ pc_init_modules(void) if (!video_card_available(gfxcard[1])) { char tempc[512] = { 0 }; device_get_name(video_card_getdevice(gfxcard[1]), 0, tempc); - swprintf(temp, sizeof(temp), (wchar_t *) "Video card #2 \"%hs\" is not available due to missing ROMs in the roms/video directory. Disabling the second video card.", tempc); + swprintf(temp, sizeof_w(temp), (wchar_t *) "Video card #2 \"%hs\" is not available due to missing ROMs in the roms/video directory. Disabling the second video card.", tempc); ui_msgbox_header(MBX_INFO, (wchar_t *) IDS_2129, temp); gfxcard[1] = 0; } diff --git a/src/win/win_about.c b/src/win/win_about.c index f0c692b75..82b327d2e 100644 --- a/src/win/win_about.c +++ b/src/win/win_about.c @@ -43,9 +43,9 @@ AboutDialogCreate(HWND hwnd) }; wchar_t emu_version[256]; - i = swprintf(emu_version, sizeof(emu_version), L"%ls v%ls", EMU_NAME_W, EMU_VERSION_FULL_W); + i = swprintf(emu_version, sizeof_w(emu_version), L"%ls v%ls", EMU_NAME_W, EMU_VERSION_FULL_W); #ifdef EMU_GIT_HASH - i += swprintf(&emu_version[i], sizeof(emu_version) - i, L" [%ls]", EMU_GIT_HASH_W); + i += swprintf(&emu_version[i], sizeof_w(emu_version) - i, L" [%ls]", EMU_GIT_HASH_W); #endif #if defined(__arm__) || defined(__TARGET_ARCH_ARM) @@ -59,7 +59,7 @@ AboutDialogCreate(HWND hwnd) #else # define ARCH_STR L"unknown" #endif - swprintf(&emu_version[i], sizeof(emu_version) - i, L" [%ls, %ls]", ARCH_STR, plat_get_string(IDS_DYNAREC)); + swprintf(&emu_version[i], sizeof_w(emu_version) - i, L" [%ls, %ls]", ARCH_STR, plat_get_string(IDS_DYNAREC)); tdconfig.cbSize = sizeof(tdconfig); tdconfig.hwndParent = hwnd;