$OpenBSD: patch-src_unix_utilsunx_cpp,v 1.1.1.1 2004/07/16 21:01:36 todd Exp $ --- src/unix/utilsunx.cpp.orig Mon Apr 7 04:03:01 2003 +++ src/unix/utilsunx.cpp Thu Jun 26 11:05:10 2003 @@ -864,8 +864,7 @@ static bool wxGetHostNameInternal(wxChar bool ok = uname(&uts) != -1; if ( ok ) { - wxStrncpy(buf, wxConvertMB2WX(uts.nodename), sz - 1); - buf[sz] = wxT('\0'); + strlcpy(buf, wxConvertMB2WX(uts.nodename), sz); } #elif defined(HAVE_GETHOSTNAME) bool ok = gethostname(buf, sz) != -1; @@ -920,7 +919,7 @@ bool wxGetFullHostName(wxChar *buf, int else { // the canonical name - wxStrncpy(buf, wxConvertMB2WX(host->h_name), sz); + strlcpy(buf, wxConvertMB2WX(host->h_name), sz); } } //else: it's already a FQDN (BSD behaves this way) @@ -936,7 +935,7 @@ bool wxGetUserId(wxChar *buf, int sz) *buf = wxT('\0'); if ((who = getpwuid(getuid ())) != NULL) { - wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1); + strlcpy (buf, wxConvertMB2WX(who->pw_name), sz); return TRUE; } @@ -955,9 +954,9 @@ bool wxGetUserName(wxChar *buf, int sz) char *comma = strchr(who->pw_gecos, ','); if (comma) *comma = '\0'; // cut off non-name comment fields - wxStrncpy (buf, wxConvertMB2WX(who->pw_gecos), sz - 1); + strlcpy (buf, wxConvertMB2WX(who->pw_gecos), sz); #else // !HAVE_PW_GECOS - wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1); + strlcpy (buf, wxConvertMB2WX(who->pw_name), sz); #endif // HAVE_PW_GECOS/!HAVE_PW_GECOS return TRUE; }