jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 12 ++++++------ xmlsecurity/source/xmlsec/nss/nssinitializer.cxx | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-)
New commits: commit 9147a19d2469b9a641d51c37d33bf874311f8e94 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Mar 30 13:57:06 2025 +0100 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Mar 30 17:07:52 2025 +0200 Use osl_getEnvironment instead of getenv Avoids conversion to OUString; and is Unicode-safe on Windows. Change-Id: Idd82f589ae9bf692ce2e73f84cb664a68156915a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183507 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx index 4c74aaddf449..23227b49c7a6 100644 --- a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx +++ b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx @@ -29,6 +29,7 @@ #include <rtl/bootstrap.hxx> #include <rtl/string.hxx> #include <osl/file.hxx> +#include <osl/process.h> #include <osl/thread.h> #include <sal/log.hxx> #include <comphelper/diagnose_ex.hxx> @@ -176,13 +177,13 @@ const OUString & ONSSInitializer::getMozillaCurrentProfile(const css::uno::Refer m_bIsNSSinitialized = true; // first, try to get the profile from "MOZILLA_CERTIFICATE_FOLDER" - const char* pEnv = getenv("MOZILLA_CERTIFICATE_FOLDER"); - if (pEnv) + if (OUString pEnv; osl_getEnvironment(u"MOZILLA_CERTIFICATE_FOLDER"_ustr.pData, &pEnv.pData) == osl_Process_E_None + && !pEnv.isEmpty()) { SAL_INFO( "xmlsecurity.xmlsec", "Using Mozilla profile from MOZILLA_CERTIFICATE_FOLDER=" << pEnv); - m_sNSSPath = OStringToOUString(pEnv, osl_getThreadTextEncoding()); + m_sNSSPath = pEnv; } // second, try to get saved user-preference @@ -284,9 +285,10 @@ css::uno::Sequence<css::xml::crypto::NSSProfile> SAL_CALL ONSSInitializer::getNS } aProfileList.push_back({u"MANUAL"_ustr, sUserSelect, mozilla::MozillaProductType_Default}); - const char* pEnv = getenv("MOZILLA_CERTIFICATE_FOLDER"); + OUString pEnv; + osl_getEnvironment(u"MOZILLA_CERTIFICATE_FOLDER"_ustr.pData, &pEnv.pData); aProfileList.push_back({u"MOZILLA_CERTIFICATE_FOLDER"_ustr, - pEnv ? OStringToOUString(pEnv, osl_getThreadTextEncoding()) : OUString(), + pEnv, mozilla::MozillaProductType_Default}); return comphelper::containerToSequence(aProfileList); commit c16c8b78fadbafcc2e75c581510d17692c718993 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Mar 30 13:11:29 2025 +0100 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Mar 30 17:07:41 2025 +0200 Use osl_getEnvironment instead of getenv Avoids conversion to OUString; and is Unicode-safe on Windows. Change-Id: I39fc7af8822850a187efb108e5f862a9863152fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183506 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index 21258af12944..1fad8ca13d14 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -1038,11 +1038,11 @@ void addJavaInfosFromPath( { #if !defined JVM_ONE_PATH_CHECK // Get Java from PATH environment variable - char *szPath= getenv("PATH"); - if(!szPath) + OUString usAllPath; + if (osl_getEnvironment(u"PATH"_ustr.pData, &usAllPath.pData) != osl_Process_E_None + || usAllPath.isEmpty()) return; - OUString usAllPath(szPath, strlen(szPath), osl_getThreadTextEncoding()); sal_Int32 nIndex = 0; do { @@ -1092,10 +1092,10 @@ void addJavaInfoFromJavaHome( // variable. We set it in our build environment for build-time programs, though, // so it is set when running unit tests that involve Java functionality. (Which affects // at least CppunitTest_dbaccess_dialog_save, too, and not only the JunitTest ones.) - char *szJavaHome= getenv("JAVA_HOME"); - if(szJavaHome) + OUString sHome; + if (osl_getEnvironment(u"JAVA_HOME"_ustr.pData, &sHome.pData) == osl_Process_E_None + && !sHome.isEmpty()) { - OUString sHome(szJavaHome, strlen(szJavaHome), osl_getThreadTextEncoding()); OUString sHomeUrl; if(File::getFileURLFromSystemPath(sHome, sHomeUrl) == File::E_None) {