X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14d63513822a9a91697508ecd37f95bac8af662e..475be9ce0003489c7330587cc51961d52043b289:/src/os2/utils.cpp diff --git a/src/os2/utils.cpp b/src/os2/utils.cpp index e3bc440f27..5a03ba30f3 100644 --- a/src/os2/utils.cpp +++ b/src/os2/utils.cpp @@ -93,13 +93,12 @@ bool wxGetHostName( wxChar* zBuf, int nMaxSize ) ,(void*)zBuf ,(ULONG)nMaxSize - 1 ); + zBuf[nMaxSize] = _T('\0'); } else { - wxStrncpy(zBuf, zSysname, nMaxSize - 1); + wxStrlcpy(zBuf, zSysname, nMaxSize); } - - zBuf[nMaxSize] = _T('\0'); #endif return *zBuf ? true : false; @@ -121,7 +120,7 @@ bool wxGetUserName( wxChar* zBuf, int nMaxSize ) #ifdef USE_NET_API wxGetUserId( zBuf, nMaxSize ); #else - wxStrncpy(zBuf, _T("Unknown User"), nMaxSize); + wxStrlcpy(zBuf, _T("Unknown User"), nMaxSize); #endif return true; } @@ -241,6 +240,14 @@ bool wxGetEnv(const wxString& var, wxString *value) static bool wxDoSetEnv(const wxString& variable, const char *value) { #if defined(HAVE_SETENV) + if ( !value ) + { +#ifdef HAVE_UNSETENV + return unsetenv(variable.mb_str()) == 0; +#else + value = _T(""); // mustn't pass NULL to setenv() +#endif + } return setenv(variable.mb_str(), value, 1 /* overwrite */) == 0; #elif defined(HAVE_PUTENV) wxString s = variable;