git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Kirill Smelkov <kirr@mns.spb.ru>
Cc: Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, msysgit@googlegroups.com
Subject: Re: [PATCH, maint] setup: make sure git_dir path is in a permanent buffer, getenv(3) case
Date: Fri, 12 Nov 2010 10:03:32 -0600	[thread overview]
Message-ID: <20101112160332.GB15141@burratino> (raw)
In-Reply-To: <20101112140329.GA29604@tugrik.mns.mnsspb.ru>

Kirill Smelkov wrote:

>     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

  reply	other threads:[~2010-11-12 16:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-11 18:08 [PATCH, maint] setup: make sure git_dir path is in a permanent buffer, getenv(3) case Kirill Smelkov
2010-11-11 18:17 ` Jonathan Nieder
2010-11-12 14:03   ` Kirill Smelkov
2010-11-12 16:03     ` Jonathan Nieder [this message]
2010-11-12 17:20       ` Kirill Smelkov
2010-11-12 18:59         ` [PATCH] tests: add GETENV_POISON option to simulate unfriendly getenv() Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101112160332.GB15141@burratino \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kirr@mns.spb.ru \
    --cc=msysgit@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).