From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 1b16db54 for ; Sat, 11 Jan 2020 17:01:33 +0000 (UTC) Received: (qmail 12627 invoked by alias); 11 Jan 2020 17:01:26 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45282 Received: (qmail 21310 invoked by uid 1010); 11 Jan 2020 17:01:26 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm1-f48.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25684. spamassassin: 3.4.2. Clear:RC:0(209.85.128.48):SA:0(-2.0/5.0):. Processed in 2.248112 secs); 11 Jan 2020 17:01:26 -0000 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.128.48 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition:user-agent; bh=T97ZLv9Yq4us9TFerBPxHnW1o6UUzvX1dakYXbEz0RE=; b=U5qVXCn9NBqEwQkKJIGna5DqvkXhIWHWcpS8E2LNHr+mejxjvdYWvhOR9l2ZdDuXNo /kuBucIS+Dx0oFdZnve7/p+u81Ssff5GcmVBToFoTXIjmkNRnUKQiz+E87Sk0G9LJuxl 97hiN4lmh69M1lrndLgMy9MsUD9LdSPXhIibwZgvijH+z0cyhLbOHsMsRu9ZiPJyDW1m mJdm02BcUWmaTwQUyfE7aMgEAwmcml1xaaGCBy9LQ2PyM50SVaxyrD8g+PfN3IBAnZ24 F+PleivWKUm+2k1rkIRxvvKo4CggInhP4lW2xhNXLYNvHgdyjEMzwa3mkXEorTzadHjM 1QRg== X-Gm-Message-State: APjAAAU71aIf9WDHLHCxiamcg4Pj7C54c9V4d0iJndhi1JgEF5D4xSDg kXzGJN8N+ebJWY5cNlja3uOyE2+3 X-Google-Smtp-Source: APXvYqz8YTGi0vBXj+GLWlgHzXmixPfvCq0Fm7cCGc2qOlNAgYjb88RdbZr02gyNIAV2TpguHgTHwg== X-Received: by 2002:a7b:c946:: with SMTP id i6mr10641512wml.28.1578762050016; Sat, 11 Jan 2020 09:00:50 -0800 (PST) Date: Sat, 11 Jan 2020 17:00:47 +0000 From: Stephane Chazelas To: Zsh hackers list Subject: [bug] :P modifier and symlink loops Message-ID: <20200111170047.ifjsdd5lfeksqyaa@chaz.gmail.com> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20180716 Hi, 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: /tmp/loop/../foo/.. (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? -- Stephane