Page MenuHome GnuPG

w32: putenv in Microsoft runtime doesn't support GNU extension
Closed, ResolvedPublic

Description

Tested:

#include <stdlib.h>
#include <stdio.h>

int
main (int argc, const char *argv[])
{
  char *s;

  putenv ("NAME=1");

#ifdef NO_EQUAL
  s = "NAME";
#else
  s = "NAME=";
#endif
  putenv (s);

  if (getenv ("NAME"))
    printf ("NAME=%s\n", getenv ("NAME"));
  else
    puts ("no environment variable: NAME");

  return 0;
}

With -DNO_EQUAL option to compile, it doesn't unsetenv.
putenv("NAME") is nonstandard extension (available in GNU implementation).

We use this nonstandard extension in common/sysutil.c:gnupg_unsetenv for Windows (!HAVE_UNSETENV).

Event Timeline

gniibe triaged this task as Normal priority.Nov 30 2022, 7:50 AM
gniibe created this task.

Actually we should switch from putenv to SetEnvironmentVariable et al. because that avoids problems wit different Windows libc versions, for example in DLLs.

gniibe changed the task status from Open to Testing.Dec 12 2022, 9:04 AM