summaryrefslogtreecommitdiff
path: root/src/mir_core/protos.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-11 15:48:26 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-11 15:48:26 +0000
commit64246e68515f9c73315a06f4f62738e45655f983 (patch)
treeb26eda28c0163b59a71bb61ce6ed5ca1301723fd /src/mir_core/protos.cpp
parent7fe4aeaec6ec0300ecd544579b462aa526b07080 (diff)
dynamic memory allocation on buffer overrun.
99.95% of strings are still printed without any need of memory allocation git-svn-id: http://svn.miranda-ng.org/main/trunk@6440 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_core/protos.cpp')
-rw-r--r--src/mir_core/protos.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/mir_core/protos.cpp b/src/mir_core/protos.cpp
index 95648a4333..d4a02757bb 100644
--- a/src/mir_core/protos.cpp
+++ b/src/mir_core/protos.cpp
@@ -48,17 +48,15 @@ void UninitProtocols()
MIR_CORE_DLL(void) ProtoLogA(struct PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args)
{
char buf[4096];
- _vsnprintf(buf, sizeof(buf), szFormat, args);
- buf[sizeof(buf)-1] = 0;
- CallService(MS_NETLIB_LOG, (WPARAM)pThis->m_hNetlibUser, (LPARAM)buf);
+ int res = _vsnprintf_s(buf, sizeof(buf), szFormat, args);
+ CallService(MS_NETLIB_LOG, (WPARAM)pThis->m_hNetlibUser, (LPARAM)((res != -1) ? buf : CMStringA().FormatV(szFormat, args)));
}
MIR_CORE_DLL(void) ProtoLogW(struct PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args)
{
WCHAR buf[4096];
- _vsnwprintf(buf, SIZEOF(buf), wszFormat, args);
- buf[SIZEOF(buf)-1] = 0;
- CallService(MS_NETLIB_LOGW, (WPARAM)pThis->m_hNetlibUser, (LPARAM)buf);
+ int res = _vsnwprintf_s(buf, SIZEOF(buf), wszFormat, args);
+ CallService(MS_NETLIB_LOGW, (WPARAM)pThis->m_hNetlibUser, (LPARAM)((res != -1) ? buf : CMStringW().FormatV(wszFormat, args)));
}
/////////////////////////////////////////////////////////////////////////////////////////