all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Demi Obenour <demiobenour@gmail.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: 19350@debbugs.gnu.org
Subject: bug#19350: #19350 24.4; Incorrect quoting of %-signs for Windows command shell
Date: Thu, 11 Aug 2016 19:11:44 -0400	[thread overview]
Message-ID: <CAJEMUN_tJ1KcCdmN7kjR+2ms5K4pbP9DYQi7mKNU5K=7bBGvDw@mail.gmail.com> (raw)
In-Reply-To: <CAM-tV-8P3SCQZ=DNfVCF+H-CrxQnr+DHnkuUzDoSDLTAdezHQw@mail.gmail.com>

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

I think that this needs to be fixed 100% — it is a security issue.

Another option is to enable command extensions every time Emacs spawns a
shell.

On Aug 10, 2016 9:00 AM, "Noam Postavsky" <npostavs@users.sourceforge.net>
wrote:
>
> tag 19350 confirmed
> severity 19350 minor
> quit
>
> > Looking at the code in subr.el, it is clear that Emacs mishandles
> > %-signs when escaping for the Windows command interpreter.
> [...]
> >
> > I deleted the lossage from the report, as there is no point in including
> > it, this being a logic error in subr.el. In fact, the buggy code is dead
> > on my machine (I run Linux) -- I happened to know about the problem on
> > Windows.
>
> Well, it would have been nice to mention which function you're talking
> about, and give an example problematic string.  I guess it's
> shell-quote-argument:
>
> Evaluating
>
> (let ((process-environment (cl-list* "ca^=with-caret"
>                                      "ca=without-caret"
>                                      process-environment)))
>   (insert (shell-command-to-string
>            (format "echo %s %s %s"
>                    "%ca%"
>                    (shell-quote-argument "%ca%")
>                    "%%CD:~,0%ca%%CD:~,0%"))))
> gives
>
> without-caret "with-caret" %ca%
>
> On the other hand, this is such an obscure corner case, I'm don't know
> if it's even worth fixing.
>
> > A method of handling % that I believe to be fully
> > robust is to follow (not precede) each series of % characters with
> > %CD:~,0%. This is an expansion that always expands to the empty
> > string. It will work provided that:
> >
> > * Command Extensions are enabled.
>
> I'm not sure if Emacs can assume this.
>
> >
> > * It is not possible for cmd.exe to interpret an environment variable
> >   whose name is the empty string.
>
> I found that adding "=emptyvar" to process-environment caused
> "Spawning child process: exec format error", so I guess this
> assumption is safe.

[-- Attachment #2: Type: text/html, Size: 2741 bytes --]

  parent reply	other threads:[~2016-08-11 23:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-11 18:43 bug#19350: 24.4; Incorrect quoting of %-signs for Windows command shell Demetrios Obenour
2016-08-10 13:00 ` bug#19350: #19350 " Noam Postavsky
2016-08-10 16:11   ` Eli Zaretskii
2016-08-11 23:11   ` Demi Obenour [this message]
2016-08-12  0:41     ` npostavs
     [not found]       ` <CAJEMUN_nkRgwCF7h03x=_jdHDLGqC+DBk0=3NNJhZTx5woW8gg@mail.gmail.com>
     [not found]         ` <CAJEMUN-HMMJu1FTDrKEmn_8nOaMhDeE8Te2JuE7jVdvuqLtbNQ@mail.gmail.com>
2016-08-15  0:44           ` Demi Obenour
2016-08-15  3:13             ` npostavs
2016-08-15 15:01               ` Eli Zaretskii
2016-08-18  2:02                 ` Demi Obenour
2016-08-18  2:21                   ` Noam Postavsky
2016-08-18 11:54                     ` Demi Obenour
2016-08-18 12:07                   ` Noam Postavsky
2016-08-18 14:17                     ` Eli Zaretskii
2016-10-03 18:47                 ` Noam Postavsky
2016-10-03 19:15                   ` Eli Zaretskii
     [not found]                     ` <CAJEMUN9xcizd9rNYiZueg4gjRAcPxh4V_JZdaSt5jr-P4LRe-A@mail.gmail.com>
2016-10-03 19:38                       ` Demi Obenour
2018-02-09  0:17                         ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJEMUN_tJ1KcCdmN7kjR+2ms5K4pbP9DYQi7mKNU5K=7bBGvDw@mail.gmail.com' \
    --to=demiobenour@gmail.com \
    --cc=19350@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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.