help / color / Atom feed
* [bug] :P modifier and symlink loops
@ 2020-01-11 17:00 Stephane Chazelas
  0 siblings, 0 replies; only message in thread
From: Stephane Chazelas @ 2020-01-11 17:00 UTC (permalink / raw)
  To: Zsh hackers list


I've got the feeling it's been discussed before, but could not
find it in the archives.

$ ln -s loop /tmp/
$ f=/tmp/loop strace ~/install/cvs/zsh/Src/zsh -c '$f:P'
readlink("/tmp/loop", "loop", 4096)     = 4
readlink("/tmp/loop", "loop", 4096)     = 4
readlink("/tmp/loop", "loop", 4096)     = 4
readlink("/tmp/loop", "loop", 4096)     = 4
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR,
si_addr=0x7ffec7a345e0} ---
+++ killed by SIGSEGV +++

possibly stack overflow caused by unbound recursion or buffer
overflow on /tmp/loop/loop... but the bigger question is what to
do here.

The ELOOP problem is usually addressed by giving up after an
arbitrary number of symlinks has been resolved (regardless of
whether there is indeed a loop or not) in the lookup of the
file, but here $f:P *has* to expand to something, so what should
that be?

For instance, for

cd /
file=bin/../tmp/loop/../foo/.. above?

The only thing I can think of is expand to:


(maybe done by first doing a stat(the-file); if it returns
ELOOP, do a stat() at each stage of the resolution and give up
on the first ELOOP).

Any other idea?


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-11 17:00 [bug] :P modifier and symlink loops Stephane Chazelas


Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git