From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25452 invoked by alias); 15 Apr 2017 01:24:31 -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: X-Seq: 40973 Received: (qmail 8015 invoked from network); 15 Apr 2017 01:24:31 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 0.663697 secs); 15 Apr 2017 01:24:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=aTEXFxKziGWsTLEAGjvFV9/WkKz898CFDlaXWHXE4oc=; b=cr2VhuSj EQKSFBnDB+ERFjtQZ7AX5/cePWZ3nWJS6xLFtnoNxNGhHD9ONcpJsmsyNHbBFsJg XiQRc6CcmSLOYV8yvH1d1ZKxfo2F5dvi8RJctSYmv28epH65bHH8hYnHcm+1sbwi KHrPZrNu5ue8bZugpt9DQN7la8ZWca8A3i6rIKyoDKpbhHK2xCj2CqOyhYetMjHw 2CWxGYoYBaEWYYvraAHP1RcyhWe39L8T+J5/nBmNKFzZ0WxrYCj6f9Z40OXz1VUR YI+e32pDTChnj2L+tUg5eD74BX5mSdZogIP/KFkoyhR11TzaoFhLbuc03DN1fuFm 5Iz/7rXXJTzspw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=aTEXFxKziGWsTLEAGjvFV9/WkKz898CFDlaXWHXE4oc=; b=rVoG4Mcr ZlktnwrPMtLXfuSisqKVxPIKUI5qePNbd9lTyDWvROLxqX9C5VI/YTA8TFJ68y4j GbzIHAEThO2+1nckE8b3yjxL8wX4xuC8JonCR6PH44S0Vq1ts+uSu+Q5WHJGI0Fj id8EXkRsoZrYuhJEZlOkc9wVuVvBbyy9oNvcwCClHqNG1DyH4os5aodxgfuCg9XQ LZ9H9kSuv4+ws7ExyTBLX8mPWlx8RcBTTmu/fqy8h261rT4MK2GQrR6BKcO04NVm V7ga4XO2a4w2itboy3yRKe02kbBwvcU7YvWfKkxZZL9olqDv7WSZUh55hEy1oN4z yX/ASqhX/XnKdA== X-ME-Sender: X-Sasl-enc: l7x4hmB1PCIThMXW8nVw10NQrhNdUgYzlBn7tD+mP52B 1492219467 Date: Sat, 15 Apr 2017 01:19:02 +0000 From: Daniel Shahaf To: Antoine Amarilli Cc: zsh-workers@zsh.org Subject: Re: Tab-completion problem through ssh when files start by dash (_remote_files:compadd:80: bad option: -@) Message-ID: <20170415011902.GB12706@fujitsu.shahaf.local2> References: <20170413174717.4w6iatxztyutpbps@mu.a3nm.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170413174717.4w6iatxztyutpbps@mu.a3nm.net> User-Agent: Mutt/1.5.23 (2014-03-12) Antoine Amarilli wrote on Thu, Apr 13, 2017 at 19:47:17 +0200: > So it looks to me like the internals of tab-completion are not properly > escaping the file names in this case, hence the warning. This is mostly > an annoyance, but maybe there could be some more problematic > implications (e.g., maybe a malicious jdoe on bar could create files > that would pass actual options to compadd and mess up more seriously > with the zsh session on foo). The «-R remote-func» option seems to be the most obvious method of injection. I'm not sure whether it requires a literal function name, or whether an anonymous function would be accepted too. > When I do this, the result looks like this: > > foo% touch blah > foo% scp blah jdoe@bar: > _remote_files:compadd:80: bad option: -@ > foo% scp test jdoe@bar: > [ACTUAL CONTENTS OF ~jdoe ON bar] I think this fixes it? diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files index 1e9fed1..a5fce9a 100644 --- a/Completion/Unix/Type/_remote_files +++ b/Completion/Unix/Type/_remote_files @@ -58,11 +58,13 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then else rempat="${(q)PREFIX%%[^./][^/]#}\*" fi + # remote filenames remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args $host ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) compset -P '*/' compset -S '/*' || (( ${args[(I)-/]} )) || suf='remote file' + # display strings for remote files and directories remdispf=(${remfiles:#*/}) remdispd=(${(M)remfiles:#*/}) @@ -77,9 +79,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then while _tags; do while _next_label files expl ${suf:-remote directory}; do [[ -n $suf ]] && - compadd "$args[@]" "$expl[@]" -d remdispf ${(q)remdispf%[*=|]} && ret=0 + compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*=|]} && ret=0 compadd ${suf:+-S/} -r "/ \t\n\-" "$args[@]" "$expl[@]" -d remdispd \ - ${(q)remdispd%/} && ret=0 + -- ${(q)remdispd%/} && ret=0 done (( ret )) || return 0 done Thanks for the report! Daniel