w32: Use _putenv_s.

* common/sysutils.c (gnupg_setenv): Use _putenv_s.

--

This may break build on original MinGW, but works well with MinGW-W64.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2023-05-16 16:25:13 +09:00
parent 5c7c6065f3
commit 86cdb49097
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054
1 changed files with 14 additions and 0 deletions

View File

@ -1148,6 +1148,19 @@ gnupg_setenv (const char *name, const char *value, int overwrite)
return setenv (name, value, overwrite);
#else /*!HAVE_SETENV*/
if (! getenv (name) || overwrite)
#ifdef HAVE_W32_SYSTEM
{
int e = _putenv_s (name, value);
if (e)
{
gpg_err_set_errno (e);
return -1;
}
else
return 0;
}
#else
{
char *buf;
@ -1165,6 +1178,7 @@ gnupg_setenv (const char *name, const char *value, int overwrite)
# endif
return putenv (buf);
}
#endif /*!HAVE_W32_SYSTEM*/
return 0;
#endif /*!HAVE_SETENV*/
}