components/mercurial/patches/CVE-2014-9462.patch
author Danek Duvall <danek.duvall@oracle.com>
Mon, 01 Jun 2015 15:54:47 -0700
branchs11u2-sru
changeset 4446 b23e280706b1
permissions -rw-r--r--
21078720 problem in UTILITY/HG
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4446
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     1
changeset:   23678:e3f30068d2eb
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     2
branch:      stable
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     3
parent:      23676:b65a01a4316b
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     4
user:        Matt Mackall <[email protected]>
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     5
date:        Mon Dec 29 13:27:02 2014 -0700
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     6
files:
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     7
   mercurial/sshpeer.py
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     8
description:
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     9
sshpeer: more thorough shell quoting
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    10
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    11
This fixes an issue spotted by Jesse Hertz.
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    12
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    13
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    14
--- a/mercurial/sshpeer.py
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    15
+++ b/mercurial/sshpeer.py
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    16
@@ -20,6 +20,8 @@ class remotelock(object):
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    17
             self.release()
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    18
 
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    19
 def _serverquote(s):
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    20
+    if not s:
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    21
+        return s
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    22
     '''quote a string for the remote shell ... which we assume is sh'''
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    23
     if re.match('[a-zA-Z0-9@%_+=:,./-]*$', s):
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    24
         return s
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    25
@@ -45,7 +47,10 @@ class sshpeer(wireproto.wirepeer):
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    26
         sshcmd = self.ui.config("ui", "ssh", "ssh")
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    27
         remotecmd = self.ui.config("ui", "remotecmd", "hg")
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    28
 
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    29
-        args = util.sshargs(sshcmd, self.host, self.user, self.port)
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    30
+        args = util.sshargs(sshcmd,
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    31
+                            _serverquote(self.host),
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    32
+                            _serverquote(self.user),
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    33
+                            _serverquote(self.port))
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    34
 
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    35
         if create:
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    36
             cmd = '%s %s %s' % (sshcmd, args,
b23e280706b1 21078720 problem in UTILITY/HG
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    37