public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Dave Chupreev <cdn.dev@yandex.ru>
Cc: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>,
	linux-man <linux-man@vger.kernel.org>,
	 GNU C Library <libc-alpha@sourceware.org>,
	Roland McGrath <roland@hack.frob.com>
Subject: Re: Bug reporting
Date: Mon, 10 May 2021 04:40:19 +1200	[thread overview]
Message-ID: <CAKgNAkgbJBM5yiOtq9X-Ber+ns_8xcp-8jr7rSYLanz+HnQWXw@mail.gmail.com> (raw)
In-Reply-To: <1492841620310804@mail.yandex.ru>

Hello,

On Fri, 7 May 2021 at 02:21, Dave Chupreev <cdn.dev@yandex.ru> wrote:
>
> Well I see, I've tried on Linux and yea I didn't find any option to insert multiple definitions.

I think the only way to insert multiple definitions is by direct
manipulation of 'extern char **environ'.

Thanks,

Michael


> 06.05.2021, 01:37, "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>:
>
> [ added a few CCs ]
>
> Hello Dave,
>
> On 5/5/21 10:30 PM, Dave Chupreev wrote:
>
>  Hello, Alejandro.
>
>  On page 138
>
>
> I guess you refer to TLPI, written by Michael.
>
>
>       1.
>
>          Your version of /unsetenv() /should check to see whether there
>          are multiple definitions of an environment variable, and remove
>          them all.
>
>  How can I add such variables which have many definitions? According to
>  *putenv* and *setenv* functions, variables with the same names are
>  replaced if encountered.
>
>
> I haven't read that part of the book yet, so I ignore the context. But
> AFAIK, that can't happen on Linux, as you pointed out (probably neither
> on Unix systems in general, but I don't know for sure, probably Michael
> does). I guess the only possibility is if an attacker somehow modified
> your environment and inserted multiple copies of an env variable.
>
> The book (TLPI) states that glibc does check that, so I digged into the
> sources and found that in <stdlib/setenv.c>, around line 290
> (<https://sourceware.org/git?p=glibc.git;a=blob;f=stdlib/setenv.c;h=893f081af6b5a21b999a4056757fd69d1386c0d4;hb=HEAD#l290>).
>  That behavior was introduced by Roland in commit
> 196980f5117c8d38f10d64bf67eeb0924651675f
> (<https://sourceware.org/git/?p=glibc.git;a=commit;h=196980f5117c8d38f10d64bf67eeb0924651675f>),
> so maybe he can better explain the reasons behind the change (the commit
> msg is quite unexplicative) if he still remembers (that goes back to 1995).
>
> Regards,
>
> Alex
>
> --
> Alejandro Colomar
> Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
> http://www.alejandro-colomar.es/



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

  parent reply	other threads:[~2021-05-09 16:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1621111620246345@mail.yandex.ru>
2021-05-05 22:37 ` Alejandro Colomar (man-pages)
     [not found]   ` <1492841620310804@mail.yandex.ru>
2021-05-09 16:40     ` Michael Kerrisk (man-pages) [this message]
2021-05-09 17:20       ` Alexander Monakov
2021-05-09 17:58         ` Michael Kerrisk (man-pages)
2004-08-09 23:38 Benno
2004-08-09 23:47 ` Roland McGrath

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=CAKgNAkgbJBM5yiOtq9X-Ber+ns_8xcp-8jr7rSYLanz+HnQWXw@mail.gmail.com \
    --to=mtk.manpages@gmail.com \
    --cc=alx.manpages@gmail.com \
    --cc=cdn.dev@yandex.ru \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=roland@hack.frob.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 read-only IMAP folder(s) and NNTP newsgroup(s).