Hi,
On Fri, Nov 19, 2021 at 02:53:06AM +0200, Lev Stipakov wrote:
> + if ((install_path[wcslen(install_path) - 1]) == L'\\')
> + {
> + install_path[wcslen(install_path) - 1] = L'\0';
> + }
> +
> + WCHAR openssl_cnf[MAX_PATH] = {0};
> + WCHAR openssl_engines[MAX_PATH] = {0};
> + WCHAR openssl_modules[MAX_PATH] = {0};
> +
> + openvpn_swprintf(openssl_cnf, _countof(install_path),
> + L"OPENSSL_CONF=%ls\\ssl\\openssl.cnf", install_path);
This needs to be _countof(openssl_cnf) - even if they are the same
today, they might not be tomorrow.
While at it, I wonder if it is more orderly to move the swprintf()
calls in the "if NULL" clause now... like this:
if (_wgetenv(L"OPENSSL_CONF") == NULL)
{
WCHAR openssl_cnf[MAX_PATH] = {0};
openvpn_swprintf(openssl_cnf, _countof(openssl_cnf),
L"OPENSSL_CONF=%ls\\ssl\\openssl.cnf", install_path);
_wputenv(openssl_cnf);
}
(I would not have brought this up for a v4, but the _countof() needs
to be fixed anyway)
Regarding Selva's comment on the scope of the memory passed to _wputenv(),
I checked MS documentation, and it does not say anything.
OTOH, it points to _wputenv_s(varname,string) which might be worth
considering...
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s?view=msvc-170
gert
--
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]
signature.asc
Description: PGP signature
_______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
