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 92327038 for ; Sat, 1 Feb 2020 17:58:25 +0000 (UTC) Received: (qmail 8089 invoked by alias); 1 Feb 2020 17:58:20 -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: 45372 Received: (qmail 27748 invoked by uid 1010); 1 Feb 2020 17:58:20 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr1-f41.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25703. spamassassin: 3.4.2. Clear:RC:0(209.85.221.41):SA:0(-2.0/5.0):. Processed in 3.306118 secs); 01 Feb 2020 17:58:20 -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.221.41 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 :references:mime-version:content-disposition:in-reply-to:user-agent; bh=cC0l8H2CnWmRhc1kdu6IuYnzcbSvAvaxG3fj2dcFNSk=; b=eaa/SUCZvXKMHSR00anKgPH+Ojyc0b9GXjGRV/qJsVpoSX7MGx2OZ/WcwHe3WgMhsz PuBOyhGnt2F94gk9cStSxFX4GjVhD5dyORVMmMbV7ZGWyEHrwhvWiu3Uoep+MLyGJCH1 giLsw8+EqLm/pzOWrpMRaqg1+yAqSTsHy+siBv9y3x1wisW9U4NV20WSXw6hTDb+UYMn L+q8B5zSkBiAVby5y7Q+mAarH0Q33Em/a9rfbGNKHsaq5VcDA3R3ci0eYp7UPBpdfk6D 1ubywHwbAmKOVCg8fVExiNCw8XiI9B7LSTQapCtyegmbI9+aUhWtGwIveOyVIqBY7T7f JyhQ== X-Gm-Message-State: APjAAAVrP0f+xK65JmLhSxtjSQiI1F8JKNp/2xmwWms+FOTrUh8Vm+BE I4Wjc5Ctlso7mtvc+VpiV1NfTu5R X-Google-Smtp-Source: APXvYqxpkFsT9DI6QwDtQIqC5o7wOZl0xVoOV8CEX+N70eae7xZ0cFcGlMCDT3dLwISREH18vaH8iQ== X-Received: by 2002:adf:f0ca:: with SMTP id x10mr2941864wro.423.1580579862593; Sat, 01 Feb 2020 09:57:42 -0800 (PST) Date: Sat, 1 Feb 2020 17:57:40 +0000 From: Stephane Chazelas To: Zsh hackers list Subject: Re: [bug] :P modifier and symlink loops Message-ID: <20200201175740.lma5dxgwufk6fpeg@chazelas.org> Mail-Followup-To: Zsh hackers list References: <20200111170047.ifjsdd5lfeksqyaa@chaz.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200111170047.ifjsdd5lfeksqyaa@chaz.gmail.com> User-Agent: NeoMutt/20180716 Ping: 2020-01-11 17:00:47 +0000, Stephane Chazelas: 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