From 62eac5d91c36b407665bf52087ef7a882e0b2f54 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Fri, 8 Aug 2014 13:22:13 +0200 Subject: [PATCH] Replace _snprintf too. --- dlls/cstrike/csx/WinCSX/WinCSX.cpp | 22 ++++++++++++++++++++-- dlls/geoip/geoip_amxx.h | 4 ---- dlls/nvault/NVault.cpp | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/dlls/cstrike/csx/WinCSX/WinCSX.cpp b/dlls/cstrike/csx/WinCSX/WinCSX.cpp index 84650674..16bc22b1 100755 --- a/dlls/cstrike/csx/WinCSX/WinCSX.cpp +++ b/dlls/cstrike/csx/WinCSX/WinCSX.cpp @@ -12,6 +12,24 @@ #include #include "commctrl.h" +size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + size_t len = vsnprintf(buffer, maxlength, fmt, ap); + va_end(ap); + + if (len >= maxlength) + { + buffer[maxlength - 1] = '\0'; + return (maxlength - 1); + } + else + { + return len; + } +} + int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, @@ -178,7 +196,7 @@ void UpdateListBox(HWND hDlg) { //if ((*b).getPosition() < 1) // umm... naaah! //continue; - _snprintf(tempbuffer, 1023, "%s", (*b).getName()); + UTIL_Format(tempbuffer, sizeof(tempbuffer)-1, "%s", (*b).getName()); SendMessage( // returns LRESULT in lResult listbox, // handle to destination control @@ -325,7 +343,7 @@ void SaveChanges(HWND hDlg) { UpdateListBox(hDlg); char buffer[256]; - _snprintf(buffer, 255, "New rank of %s: %d", name, newPosition); + UTIL_Format(buffer, sizeof(buffer)-1, "New rank of %s: %d", name, newPosition); MessageBox(hDlg, buffer, "Update succeeded", MB_OK); // In the listbox, we need to reselect the item we just updated. Use the new name. diff --git a/dlls/geoip/geoip_amxx.h b/dlls/geoip/geoip_amxx.h index 2e5ef298..e4dcb2ee 100755 --- a/dlls/geoip/geoip_amxx.h +++ b/dlls/geoip/geoip_amxx.h @@ -17,10 +17,6 @@ #include "GeoIP2/maxminddb.h" #include "amxxmodule.h" -#if defined(WIN32) - #define snprintf _snprintf -#endif - extern AMX_NATIVE_INFO geoip_natives[]; #endif //_INCLUDE_GEOIPAMXX_H diff --git a/dlls/nvault/NVault.cpp b/dlls/nvault/NVault.cpp index fe50f239..c781bac2 100755 --- a/dlls/nvault/NVault.cpp +++ b/dlls/nvault/NVault.cpp @@ -362,7 +362,7 @@ bool NVault::GetValue(const char *key, time_t &stamp, char buffer[], size_t len) sVal = m_Hash.Retrieve(sKey, st); stamp = st; - _snprintf(buffer, len, "%s", sVal.c_str()); + UTIL_Format(buffer, len, "%s", sVal.c_str()); return true; }