summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/putenv.c
AgeCommit message (Collapse)Author
2015-01-20Fix non _REENTRANT build.christos
2013-04-25Remove weak_alias since that's now in the compat_putenv.cmatt
2010-11-14Improve and simplify implementation of *env(3) functions:tron
- Use RB tree to keep track of memory allocated via setenv(3) as suggested by Enami Tsugutomo in private e-mail. This simplifies the code a lot as we no longer need to keep the size of "environ" in sync with an array of allocated environment variables. It also makes it possible to free environment variables in unsetenv(3) if something has changed the order of the "environ" array. - Fix a bug in getenv(3) and getenv_r(3) which would return bogus results e.g. for " getenv("A=B") " if an environment variable "A" with value "B=C" exists. - Clean up the internal functions: - Don't expose the read/write lock for the environment to other parts of "libc". Provide locking functions instead. - Use "bool" to report success or failure. - Use "ssize_t" or "size_t" instead of "int" for indexes. - Provide internal functions with simpler interfaces e.g. don't combine return values and reference arguments. - Don't copy "environ" into an allocated block unless we really need to grow it. Code reviewed by Joerg Sonnenberger and Christos Zoulas, tested by Joerg Sonnenberger and me. These changes also fix problems in zsh 4.3.* and pam_ssh according to Joerg.
2010-11-03Handle the case where a program attempted to cleanup the environment bychristos
setting *environ = NULL;
2010-10-25Make putenv(3) fails with EINVAL for a null pointer, or for a stringnjoly
that either miss or start with a `=' character. Adjust man page and testcase accordingly.
2010-10-05Avoid unnecessary malloc(). Since __findenv() kindly treatsenami
equal sign as an end of string, we can pass the string of form "key=value" to lookup "key".
2010-10-02Restore binary compatibility with applications which use putenv(3)tron
on constant strings (e.g. postdrop(1)): - Don't write to the environment string passed to putenv(3). - Don't overwrite the value of an existing environment string unless the memory was actually allocated by setenv(3).
2010-10-02Remember that we didn't malloc() memory for an environment variabletron
if it has been set via putenv(3).
2010-10-01make putenv POSIX compliant.christos
2003-08-07Move UCB-licensed code from 4-clause to 3-clause licence.agc
Patches provided by Joel Baker in PR 22280, verified by myself.
2000-01-22Delint.mycroft
Remove trailing ; from uses of __weak_alias(). The macro inserts this if needed.
1999-09-20back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.lukem
_DIAGASSERT() is still retained.
1999-09-16* use _DIAGASSERT() to check pointer arguments against NULL and filelukem
descriptors against -1 (as appropriate). * add actual checks which to detect stuff that would trigger_DIAGASSERT(), and attempt to return a sane error condition. * knf some code * remove some `register' decls. the first two items result in the addition of code similar to the following in various functions: _DIAGASSERT(path != NULL) #ifdef _DIAGNOSTIC if (path == NULL) { errno = EFAULT; return (-1); } #endif
1998-01-30update to lite-2perry
1997-07-21If port provides __weak_alias(), provide an Standard C and POSIX purejtc
identifier namespace by renaming non standard functions and variables such that they have a leading underscore. The library will use those names internally. Weak aliases are used to provide the original names to the API. This is only the first part of this change. It is most of the functions which are implemented in C for all NetBSD ports. Subsequent changes are to add the same support to the remaining C files, to assembly files, and to the automagically generated assembly source used for system calls. When all of the above is done, ports with weak alias support should add a definition for __weak_alias to <sys/cdefs.h>.
1997-07-13Add local.h for local prototypes.christos
Fix namespace issues for strtoq and strtouq Fix gcc warnings. Fix RCSID's
1995-12-28New-style RCS ids.thorpej
1993-11-24Change C library functions to use strchr() and strrchr() instead of index()jtc
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications to redefine index() and rindex() without effecting the library internals.
1993-08-26Declare rcsid strings so they are stored in text segment.jtc
1993-08-01Add RCS identifiers.mycroft
1993-03-21initial import of 386bsd-0.1 sourcescgd