diff --git a/src/config.c b/src/config.c index 08508ae..d71259d 100644 --- a/src/config.c +++ b/src/config.c @@ -1115,7 +1115,7 @@ static DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string, else { char section[MAX_PATH] = { 0 }; - _snprintf(section, sizeof(section), "%s?%d", g_config.process_file_name, 2); + _snprintf(section, sizeof(section) - 1, "%s?%d", g_config.process_file_name, 2); s = GetPrivateProfileStringA(section, key, "", out_string, out_size, g_config.ini_path); @@ -1135,7 +1135,7 @@ static DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string, else { char section[MAX_PATH] = { 0 }; - _snprintf(section, sizeof(section), "%s/%d", g_config.process_file_name, 2); + _snprintf(section, sizeof(section) - 1, "%s/%d", g_config.process_file_name, 2); s = GetPrivateProfileStringA(section, key, "", out_string, out_size, g_config.ini_path); @@ -1162,8 +1162,8 @@ static BOOL cfg_get_bool(LPCSTR key, BOOL default_value) static int cfg_get_int(LPCSTR key, int default_value) { - char def_value[20]; - _snprintf(def_value, sizeof(def_value), "%d", default_value); + char def_value[24]; + _snprintf(def_value, sizeof(def_value) - 1, "%d", default_value); char value[20]; cfg_get_string(key, def_value, value, sizeof(value)); diff --git a/src/dllmain.c b/src/dllmain.c index ed27aaa..bf6c556 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -58,7 +58,7 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) _snprintf( mes, - sizeof(mes), + sizeof(mes) - 1, "Please disable the '%s' compatibility mode for all game executables and " "then try to start the game again.", s); diff --git a/src/render_gdi.c b/src/render_gdi.c index c3f339f..bd88fb6 100644 --- a/src/render_gdi.c +++ b/src/render_gdi.c @@ -29,7 +29,7 @@ DWORD WINAPI gdi_render_main(void) _snprintf( warning_text, - sizeof(warning_text), + sizeof(warning_text) - 1, "-WARNING- Using slow software rendering, please update your graphics card driver (%s)", strlen(g_oglu_version) > 10 ? "" : g_oglu_version); } diff --git a/src/screenshot.c b/src/screenshot.c index 4ad3cfc..d559101 100644 --- a/src/screenshot.c +++ b/src/screenshot.c @@ -150,7 +150,7 @@ BOOL ss_take_screenshot(IDirectDrawSurfaceImpl* src) CreateDirectoryA(g_config.screenshot_dir, NULL); strftime(str_time, sizeof(str_time), "%Y-%m-%d-%H_%M_%S", localtime(&t)); - _snprintf(filename, sizeof(filename), "%s%s-%s.png", g_config.screenshot_dir, title, str_time); + _snprintf(filename, sizeof(filename) - 1, "%s%s-%s.png", g_config.screenshot_dir, title, str_time); if (src->bpp == 8 && src->palette) {