All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Bug reporting
       [not found] <1621111620246345@mail.yandex.ru>
@ 2021-05-05 22:37 ` Alejandro Colomar (man-pages)
       [not found]   ` <1492841620310804@mail.yandex.ru>
  0 siblings, 1 reply; 6+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-05-05 22:37 UTC (permalink / raw)
  To: Dave Chupreev
  Cc: linux-man, GNU C Library, Michael Kerrisk (man-pages), Roland McGrath

[ 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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug reporting
       [not found]   ` <1492841620310804@mail.yandex.ru>
@ 2021-05-09 16:40     ` Michael Kerrisk (man-pages)
  2021-05-09 17:20       ` Alexander Monakov
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-05-09 16:40 UTC (permalink / raw)
  To: Dave Chupreev
  Cc: Alejandro Colomar (man-pages), linux-man, GNU C Library, Roland McGrath

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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug reporting
  2021-05-09 16:40     ` Michael Kerrisk (man-pages)
@ 2021-05-09 17:20       ` Alexander Monakov
  2021-05-09 17:58         ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Monakov @ 2021-05-09 17:20 UTC (permalink / raw)
  To: mtk.manpages
  Cc: Dave Chupreev, Alejandro Colomar (man-pages),
	linux-man, GNU C Library, Roland McGrath



On Mon, 10 May 2021, Michael Kerrisk (man-pages) via Libc-alpha wrote:

> 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'.

You can cause a program to start with multiple definitions, because it is
possible to pass arbitrarily funny stuff as 'envp' argument to execve, such as:

- duplicated entries
- entries without a '='
- entries starting with '='
- empty strings
- "2 x 2 = 4"

All of that will be present in the exec'd program's environment array.

Alexander

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug reporting
  2021-05-09 17:20       ` Alexander Monakov
@ 2021-05-09 17:58         ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-05-09 17:58 UTC (permalink / raw)
  To: Alexander Monakov
  Cc: Dave Chupreev, Alejandro Colomar (man-pages),
	linux-man, GNU C Library, Roland McGrath

Hello ALexander,

On Mon, 10 May 2021 at 05:20, Alexander Monakov <amonakov@ispras.ru> wrote:
>
>
>
> On Mon, 10 May 2021, Michael Kerrisk (man-pages) via Libc-alpha wrote:
>
> > 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'.
>
> You can cause a program to start with multiple definitions, because it is
> possible to pass arbitrarily funny stuff as 'envp' argument to execve, such as:
>
> - duplicated entries
> - entries without a '='
> - entries starting with '='
> - empty strings
> - "2 x 2 = 4"
>
> All of that will be present in the exec'd program's environment array.

Yes. I was too focussed on thinking about what an already running
program can do to its current environment. Thanks for reminding me of
the above.

Thanks,

Michael


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bug reporting
  2014-09-26 13:41 bug reporting Ajay
@ 2014-09-26 23:51 ` brian m. carlson
  0 siblings, 0 replies; 6+ messages in thread
From: brian m. carlson @ 2014-09-26 23:51 UTC (permalink / raw)
  To: Ajay; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

On Fri, Sep 26, 2014 at 07:11:35PM +0530, Ajay wrote:
> Hello,
> 
>          I have faced a git bug. When I try to clone a git repo it shows an
> error "protocol error: bad pack header".
> 
>          This is the full error message which I got while cloning git
> project :
> 
> Clone: protocol error: bad pack header
>     $ git clone -v --progress
> http://dev.galaxylipl.com:88/galaxygit/privatenovator.git
> /home/lipl/privateschoolinnovator
>     Cloning into '/home/lipl/privatenovator'...
>     POST git-upload-pack (190 bytes)
>     remote: error: Could not read e9a6c4c684a5e8758026e8b0e25867c03332fe7c
>     remote: fatal: bad tree object e9a6c4c684a5e8758026e8b0e25867c03332fe7c
>     remote: aborting due to possible repository corruption on the remote
> side.
>     protocol error: bad pack header

This indicates some sort of corruption between the client and server.  I
notice you're cloning over HTTP.  Are you using a proxy?  Can you try
using a git, ssh, or https (without MITM) URL?  Sometimes broken proxies
can end up corrupting data.

Also, what version of git are you using on the client and the server?
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug reporting
@ 2014-09-26 13:41 Ajay
  2014-09-26 23:51 ` brian m. carlson
  0 siblings, 1 reply; 6+ messages in thread
From: Ajay @ 2014-09-26 13:41 UTC (permalink / raw)
  To: git

Hello,

          I have faced a git bug. When I try to clone a git repo it 
shows an error "protocol error: bad pack header".

          This is the full error message which I got while cloning git 
project :

Clone: protocol error: bad pack header
     $ git clone -v --progress 
http://dev.galaxylipl.com:88/galaxygit/privatenovator.git 
/home/lipl/privateschoolinnovator
     Cloning into '/home/lipl/privatenovator'...
     POST git-upload-pack (190 bytes)
     remote: error: Could not read e9a6c4c684a5e8758026e8b0e25867c03332fe7c
     remote: fatal: bad tree object 
e9a6c4c684a5e8758026e8b0e25867c03332fe7c
     remote: aborting due to possible repository corruption on the 
remote side.
     protocol error: bad pack header

I tried everything to resolve this error, I have run some commands on 
server side like :

# git fsck
# git-fsck --full
# git fsck --lost-found
# git repack
# git gc

         But nothing worked for me and the error is still same. I tried 
to find the corrupt file but I was unable to find.

         Please check this issue and provide me proper solution for this.

Thanks & Regards,
Ajay Dadgas

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-09 17:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1621111620246345@mail.yandex.ru>
2021-05-05 22:37 ` Bug reporting Alejandro Colomar (man-pages)
     [not found]   ` <1492841620310804@mail.yandex.ru>
2021-05-09 16:40     ` Michael Kerrisk (man-pages)
2021-05-09 17:20       ` Alexander Monakov
2021-05-09 17:58         ` Michael Kerrisk (man-pages)
2014-09-26 13:41 bug reporting Ajay
2014-09-26 23:51 ` brian m. carlson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.