mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
w32: Fix gnupg_unsetenv.
* common/sysutils.c (gnupg_unsetenv): Don't use nonstandard extension of "NAME", but "NAME=". -- Microsoft implementation of putenv works to remove an environment variable by "NAME=". POSIX doesn't say that putenv with "NAME=" has same effect. GNU implementation doesn't support this way for removal of environment variable. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
de0c563f29
commit
8e8971403f
@ -1192,19 +1192,28 @@ gnupg_unsetenv (const char *name)
|
|||||||
#else /*!HAVE_UNSETENV*/
|
#else /*!HAVE_UNSETENV*/
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
int r;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
{
|
{
|
||||||
gpg_err_set_errno (EINVAL);
|
gpg_err_set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
buf = xtrystrdup (name);
|
buf = strconcat (name, "=", NULL);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
r = putenv (buf);
|
||||||
|
# ifdef HAVE_W32_SYSTEM
|
||||||
|
/* For Microsoft implementation, we can free the memory in this
|
||||||
|
use case. */
|
||||||
|
xfree (buf);
|
||||||
|
# else
|
||||||
# if __GNUC__
|
# if __GNUC__
|
||||||
# warning no unsetenv - trying putenv but leaking memory.
|
# warning no unsetenv - trying putenv but leaking memory.
|
||||||
# endif
|
# endif
|
||||||
return putenv (buf);
|
# endif
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
#endif /*!HAVE_UNSETENV*/
|
#endif /*!HAVE_UNSETENV*/
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user