Revision 820d7650cc670d3e4195aad3a5343158c316e8fa authored by Junio C Hamano on 26 July 2017, 17:24:20 UTC, committed by Junio C Hamano on 28 July 2017, 22:51:14 UTC
When commands like "git fetch" talk with ssh://$rest_of_URL/, the
code splits $rest_of_URL into components like host, port, etc., and
then spawns the underlying "ssh" program by formulating argv[] array
that has:

 - the path to ssh command taken from GIT_SSH_COMMAND, etc.

 - dashed options like '-batch' (for Tortoise), '-p <port>' as
   needed.

 - ssh_host, which is supposed to be the hostname parsed out of
   $rest_of_URL.

 - then the command to be run on the other side, e.g. git
   upload-pack.

If the ssh_host ends up getting '-<anything>', the argv[] that is
used to spawn the command becomes something like:

    { "ssh", "-p", "22", "-<anything>", "command", "to", "run", NULL }

which obviously is bogus, but depending on the actual value of
"<anything>", will make "ssh" parse and use it as an option.

Prevent this by forbidding ssh_host that begins with a "-".

Noticed-by: Joern Schneeweisz of Recurity Labs
Reported-by: Brian at GitLab
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c8dd1e3
History
File Mode Size
.gitignore -rw-r--r-- 7 bytes
README -rw-r--r-- 10.6 KB
TEAMS -rw-r--r-- 2.0 KB
bg.po -rw-r--r-- 455.5 KB
ca.po -rw-r--r-- 342.5 KB
de.po -rw-r--r-- 369.4 KB
fr.po -rw-r--r-- 364.3 KB
git.pot -rw-r--r-- 225.0 KB
is.po -rw-r--r-- 3.1 KB
it.po -rw-r--r-- 128.2 KB
ko.po -rw-r--r-- 363.2 KB
pt_PT.po -rw-r--r-- 99.8 KB
ru.po -rw-r--r-- 429.3 KB
sv.po -rw-r--r-- 353.1 KB
vi.po -rw-r--r-- 390.6 KB
zh_CN.po -rw-r--r-- 334.5 KB

README

back to top