git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH, maint] setup: make sure git_dir path is in a permanent buffer, getenv(3) case

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 12, 2010, 16:03 UTC
Message-ID
<20101112160332.GB15141@burratino>
In-Reply-To
<20101112140329.GA29604@tugrik.mns.mnsspb.ru>
Kirill Smelkov wrote:
Show 13 quoted lines
>     static void run_service(const char **argv)
>     {
>             const char *encoding = getenv("HTTP_CONTENT_ENCODING");
>             const char *user = getenv("REMOTE_USER");
>             const char *host = getenv("REMOTE_ADDR");
> 
> 
> etc...
> 
> 
> To me, it's very unfortunate that subsequent getenv() could overwrite
> previous getenv() result, but according to `man 3 getenv` all these
> places are buggy.

Right, but do we know of any platforms that work that way currently? We could make getenv() rotate between a few buffers on such platforms (probably 10 or so would take care of the longest runs).

> Maybe we'll need something like our own xgetenv() which will keep vars
> in some kind of hash tab so that get/put on other vars do not interfere
> with what was originally returned by xgetenv().

For examples that store the result like you pointed out (which store the result from getenv), something like that would be needed if we want them to work on platforms where putenv shifts everything.

> Unfortunately I can't afford myself to dive into all this, so please
> choose what you like more.

I think we ought to fix this properly in the end. But if you want a quick workaround, maybe the vcs-svn/string_pool lib could help you.

Hope that helps, Jonathan

Previous: Kirill SmelkovNext: Kirill Smelkov
Message 4 of 6 in “setup: make sure git_dir path is in a permanent buffer, getenv(3) case”
  1. setup: make sure git_dir path is in a permanent buffer, getenv(3) caseKirill Smelkov, Nov 11, 2010
  2. Jonathan NiederNov 11, 2010
  3. Kirill SmelkovNov 12, 2010
  4. Jonathan NiederNov 12, 2010
  5. Kirill SmelkovNov 12, 2010
  6. tests: add GETENV_POISON option to simulate unfriendly getenv()Jonathan Nieder, Nov 12, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.