[Bug 861132] Re: setenv ("NAME", NULL) corrupts environment

Ubuntu QA's Bug Bot bug-stats at murraytwins.com
Wed Sep 28 08:10:58 UTC 2011


The attachment "Proposed fix" of this bug report has been identified as
being a patch.  The ubuntu-reviewers team has been subscribed to the bug
report so that they can review the patch.  In the event that this is in
fact not a patch you can resolve this situation by removing the tag
'patch' from the bug report and editing the attachment so that it is not
flagged as a patch.  Additionally, if you are member of the ubuntu-
sponsors please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by
Brian Murray.  Please contact him regarding any issues with the action
taken in this bug report.]

** Tags added: patch

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to eglibc in Ubuntu.
https://bugs.launchpad.net/bugs/861132

Title:
  setenv ("NAME", NULL) corrupts environment

Status in Embedded GLIBC:
  Confirmed
Status in “eglibc” package in Ubuntu:
  New

Bug description:
  setenv ("NAME", NULL) corrupts the environment.  It doesn't seem
  specified what the function should do when value is NULL, but the code
  does check for it - it just does the wrong thing:

  stdlib/setenv.c:
  ...
  __add_to_environ (name, value, combined, replace)
  ...
    const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
  ...
        memcpy (new_value, name, namelen);
        new_value[namelen] = '=';
        memcpy (&new_value[namelen + 1], value, vallen);
  ...

  i.e. the new value is set to "NAME=" without the trailing nul
  character.

  Found in bug 861123 where indicator-datetime does a:
  x = g_strdup (getenv ("NAME"));
  unsetenv ("NAME");
  // do something
  setenv ("NAME", x);

To manage notifications about this bug go to:
https://bugs.launchpad.net/eglibc/+bug/861132/+subscriptions




More information about the foundations-bugs mailing list