[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getenv() and i370-ibm-openedition
From: |
Thomas Dickey |
Subject: |
Re: getenv() and i370-ibm-openedition |
Date: |
Wed, 23 Jul 2014 19:01:22 -0400 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Wed, Jul 23, 2014 at 04:26:55PM -0600, Paul Gilmartin wrote:
> Hello, bug-ncurses,
>
> In:
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html#tag_16_194_03
> one may read:
> ...
> |char *getenv(const char */name/);|
> ...
> ^[CX <javascript:open_code('CX')>] [Option Start] The returned
> string pointer might be invalidated or [Option End] the string
> content might be overwritten by a subsequent call to /getenv/(),
> ^[CX <javascript:open_code('CX')>] [Option Start] /setenv/()
> <http://pubs.opengroup.org/onlinepubs/9699919799/functions/setenv.html>,
> /unsetenv/()
> <http://pubs.opengroup.org/onlinepubs/9699919799/functions/unsetenv.html>,
> or (if supported) /putenv/()
> <http://pubs.opengroup.org/onlinepubs/9699919799/functions/putenv.html>
> ...
>
> IBM is the only vendor I've known to exploit this behavior by copying the
> string value into a volatile buffer. (Their intent was to spare the
> programmer
> the onus of keeping the argument to putenv() in static storage.)
> This caused
> me problems in Lynx; Tom Dickey generously incorporated my patch to copy the
> returned value.
>
> But I'm now informed that IBM supplies an alternative, __getenv(), which
> simply returns a pointer to the string the programmer supplied to putenv()
> after the "=". Might the easy circumvention be:
>
> #if defined(__MVS__)
> #include <stdlib.h>
> #define getenv __getenv
> #endif
>
> ... so getenv is redefined somewhere after any header file mentioning
> getenv but before any call to getenv() in ncurses?
hmm: is there some place where I'm not strdup'ing a long-lived value from
getenv?
--
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net
signature.asc
Description: Digital signature