From: Włodzimierz Skiba Date: Tue, 22 Nov 2005 11:57:55 +0000 (+0000) Subject: Safe wxStrncpy usage. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/86f6a6d19dd83364e32f35873009fc2bb762091c Safe wxStrncpy usage. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36225 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 672db64220..21e9a0fdfb 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -294,7 +294,8 @@ bool wxGetUserName(wxChar *buf, int maxSize) wxString name; if(!key.QueryValue(wxEmptyString, name)) return false; - wxStrncpy(buf, name.c_str(), maxSize); + wxStrncpy(buf, name.c_str(), maxSize-1); + buf[maxSize-1] = _T('\0'); return true; #elif defined(USE_NET_API) CHAR szUserName[256];