$OpenBSD: patch-src_common_log_cpp,v 1.1.1.1 2004/07/16 21:01:35 todd Exp $ --- src/common/log.cpp.orig 2003-09-20 20:24:25.000000000 +1000 +++ src/common/log.cpp 2003-10-04 13:24:11.000000000 +1000 @@ -248,22 +248,13 @@ void wxLogVerbose(const wxChar *szFormat if ( IsLoggingEnabled() && wxLog::IsAllowedTraceMask(mask) ) { wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); - wxChar *p = s_szBuf; - size_t len = s_szBufSize; - wxStrncpy(s_szBuf, _T("("), len); - len -= 1; // strlen("(") - p += 1; - wxStrncat(p, mask, len); - size_t lenMask = wxStrlen(mask); - len -= lenMask; - p += lenMask; - - wxStrncat(p, _T(") "), len); - len -= 2; - p += 2; - - wxVsnprintf(p, len, szFormat, argptr); - + strlcpy(s_szBuf, _T("("), s_szBufSize); + strlcat(s_szBuf, mask, s_szBufSize); + strlcat(s_szBuf, _T(") "), s_szBufSize); + + size_t len = strlen(s_szBuf); + wxVsnprintf(s_szBuf + len, s_szBufSize - len, szFormat, argptr); + wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL)); } } @@ -314,7 +305,7 @@ void wxLogSysErrorHelper(long lErrCode) wxChar szErrMsg[LOG_BUFFER_SIZE / 2]; wxSnprintf(szErrMsg, WXSIZEOF(szErrMsg), _(" (error %ld: %s)"), lErrCode, wxSysErrorMsg(lErrCode)); - wxStrncat(s_szBuf, szErrMsg, s_szBufSize - wxStrlen(s_szBuf)); + strlcat(s_szBuf, szErrMsg, s_szBufSize); wxLog::OnLog(wxLOG_Error, s_szBuf, time(NULL)); } @@ -725,8 +716,8 @@ void wxLogStderr::DoLogString(const wxCh #endif // MSW #if defined(__WXMAC__) && !defined(__DARWIN__) && wxUSE_GUI Str255 pstr ; - strcpy( (char*) pstr , str.c_str() ) ; - strcat( (char*) pstr , ";g" ) ; + strlcpy( (char*) pstr , str.c_str(), sizeof(pstr)) ; + strlcat( (char*) pstr , ";g", sizeof(pstr)) ; c2pstr( (char*) pstr ) ; Boolean running = false ; @@ -946,8 +937,7 @@ const wxChar *wxSysErrorMsg(unsigned lon // copy it to our buffer and free memory if( lpMsgBuf != 0 ) { - wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1); - s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxT('\0'); + strlcpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf)); LocalFree(lpMsgBuf);