All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joachim Durchholz <jo@durchholz.org>
To: git@vger.kernel.org
Subject: problem with backslash in directory name
Date: Fri, 7 Apr 2017 08:12:49 +0200	[thread overview]
Message-ID: <9e3af7d6-a2c1-2673-53cc-d4c5105d9051@durchholz.org> (raw)

Hi all,

I'm having a problem with submodules that reside in directories that 
(unwisely) contain a backslash in their name.


Transcript:

### Arrange

$ git init main
Initialized empty Git repository in /tmp/test/main/.git/

$ git init sub\\with\\backslash
Initialized empty Git repository in /tmp/test/sub\with\backslash/.git/
# This looks okay: the shell interpreted \\ as \,
# so we get sub\with\backslash

# Create a log entry in sub\with\backslash
# (it can't be added as a submodule otherwise)
# ((actually I think it's a misfeature, my current use case would be
# easier if git didn't insist on having a log in submodules))
$ touch sub\\with\\backslash/empty.file
$ git -C sub\\with\\backslash add empty.file
$ git -C sub\\with\\backslash commit -m "Added empty.file"
[master (root-commit) a27a485] Added empty.file
  1 file changed, 0 insertions(+), 0 deletions(-)
  create mode 100644 empty.file

### Act/Assert

$ git -C main submodule add ../sub\\with\\backslash
fatal: repository '/tmp/test/sub\witackslash' does not exist
fatal: clone of '/tmp/test/sub\witackslash' into submodule path 
'sub\with\backslash' failed
# The first "fatal:" line talks about "witackslash"
# Um... "ackslash"? Now that's a nice nickname for a CVE :-)

# Okay, let's see what's actually in that message
$ git -C main submodule add ../sub\\with\\backslash 2>&1 | xxd
00000000: 6661 7461 6c3a 2072 6570 6f73 6974 6f72  fatal: repositor
00000010: 7920 272f 746d 702f 7465 7374 2f73 7562  y '/tmp/test/sub
00000020: 5c77 6974 6808 6163 6b73 6c61 7368 2720  \with.ackslash'
00000030: 646f 6573 206e 6f74 2065 7869 7374 0a66  does not exist.f
00000040: 6174 616c 3a20 636c 6f6e 6520 6f66 2027  atal: clone of '
00000050: 2f74 6d70 2f74 6573 742f 7375 625c 7769  /tmp/test/sub\wi
00000060: 7468 0861 636b 736c 6173 6827 2069 6e74  th.ackslash' int
00000070: 6f20 7375 626d 6f64 756c 6520 7061 7468  o submodule path
00000080: 2027 7375 625c 7769 7468 5c62 6163 6b73   'sub\with\backs
00000090: 6c61 7368 2720 6661 696c 6564 0a         lash' failed.

# Yeah, there's a 0x08 at offset 0x25.
# It's pretty strange that it is eliding the w following the \b,
# not the h preceding it.


So... something inside "git submodule add" is replacing the \b with a 
backspace control code.


Next I tried something nasty:

$ mv sub\\with\\backslash 'sub: $(bc)'
git -C main submodule add '../sub: $(bc)'
Cloning into ' $(bc)'...
done.

Whatever that "something" is, it is not doing shell expansion, otherwise 
it would have started an interactive calculator session.
Phew :-)
I'm still a bit uneasy because I don't know what other escape sequences 
might get interpreted, and what their effects are.

             reply	other threads:[~2017-04-07  6:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07  6:12 Joachim Durchholz [this message]
2017-04-07  6:30 ` problem with backslash in directory name Jeff King
2017-04-07  8:24   ` Joachim Durchholz
2017-04-07  8:40   ` Joachim Durchholz
2017-04-07 16:53   ` Brandon Williams
2017-04-07 16:55     ` Stefan Beller
2017-04-07 17:23       ` [PATCH] submodule: prevent backslash expantion in submodule names Brandon Williams
2017-04-07 17:35         ` Joachim Durchholz
2017-04-08 10:59         ` Jeff King
2017-04-08 20:32           ` Joachim Durchholz
2017-04-17  3:09           ` Junio C Hamano

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=9e3af7d6-a2c1-2673-53cc-d4c5105d9051@durchholz.org \
    --to=jo@durchholz.org \
    --cc=git@vger.kernel.org \
    /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.
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.