~ubuntu-branches/ubuntu/trusty/mercurial/trusty-security

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2014-9390.pt2

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers, Jamie Strandboge, Marc Deslauriers
  • Date: 2015-06-17 10:51:42 UTC
  • Revision ID: package-import@ubuntu.com-20150617105142-5pe4odmv44b1p509
Tags: 2.8.2-1ubuntu1.3
[ Jamie Strandboge ]
* SECURITY UPDATE: fix for improperly handling case-insensitive paths on
  Windows and OS X clients
  - http://selenic.com/repo/hg-stable/rev/885bd7c5c7e3
  - http://selenic.com/repo/hg-stable/rev/c02a05cc6f5e
  - http://selenic.com/repo/hg-stable/rev/6dad422ecc5a
  - CVE-2014-9390
  - LP: #1404035

[ Marc Deslauriers ]
* SECURITY UPDATE: arbitrary command exection via crafted repository
  name in a clone command
  - d/p/from_upstream__sshpeer_more_thorough_shell_quoting.patch: add
    more thorough shell quoting to mercurial/sshpeer.py.
  - CVE-2014-9462
* debian/patches/fix_ftbfs_patchbomb_test.patch: fix patchbomb test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Backport of:
 
2
 
 
3
Origin: c02a05cc6f5e661b09b0b0c65ec7bc874e161f9c (backport)
 
4
# HG changeset patch
 
5
# User Augie Fackler <raf@durin42.com>
 
6
# Date 1418753297 18000
 
7
# Node ID c02a05cc6f5e661b09b0b0c65ec7bc874e161f9c
 
8
# Parent  7a5bcd471f2ef302613b8551a79081d46d04be6e
 
9
pathauditor: check for codepoints ignored on OS X
 
10
 
 
11
Index: mercurial-2.8.2/mercurial/scmutil.py
 
12
===================================================================
 
13
--- mercurial-2.8.2.orig/mercurial/scmutil.py
 
14
+++ mercurial-2.8.2/mercurial/scmutil.py
 
15
@@ -5,6 +5,7 @@
 
16
 # This software may be used and distributed according to the terms of the
 
17
 # GNU General Public License version 2 or any later version.
 
18
 
 
19
+import encoding
 
20
 from i18n import _
 
21
 from mercurial.node import nullrev
 
22
 import util, error, osutil, revset, similar, encoding, phases, parsers
 
23
@@ -19,6 +20,9 @@ else:
 
24
 systemrcpath = scmplatform.systemrcpath
 
25
 userrcpath = scmplatform.userrcpath
 
26
 
 
27
+def _lowerclean(s):
 
28
+    return encoding.hfsignoreclean(s.lower())
 
29
+
 
30
 def nochangesfound(ui, repo, excluded=None):
 
31
     '''Report no changes for push/pull, excluded is None or a list of
 
32
     nodes excluded from the push/pull.
 
33
@@ -143,11 +147,11 @@ class pathauditor(object):
 
34
             raise util.Abort(_("path ends in directory separator: %s") % path)
 
35
         parts = util.splitpath(path)
 
36
         if (os.path.splitdrive(path)[0]
 
37
-            or parts[0].lower() in ('.hg', '.hg.', '')
 
38
+            or _lowerclean(parts[0]) in ('.hg', '.hg.', '')
 
39
             or os.pardir in parts):
 
40
             raise util.Abort(_("path contains illegal component: %s") % path)
 
41
-        if '.hg' in path.lower():
 
42
-            lparts = [p.lower() for p in parts]
 
43
+        if '.hg' in _lowerclean(path):
 
44
+            lparts = [_lowerclean(p.lower()) for p in parts]
 
45
             for p in '.hg', '.hg.':
 
46
                 if p in lparts[1:]:
 
47
                     pos = lparts.index(p)
 
48
Index: mercurial-2.8.2/tests/test-commit.t
 
49
===================================================================
 
50
--- mercurial-2.8.2.orig/tests/test-commit.t
 
51
+++ mercurial-2.8.2/tests/test-commit.t
 
52
@@ -306,4 +306,21 @@ commit copy
 
53
        0         0       6  .....       0 26d3ca0dfd18 000000000000 000000000000 (re)
 
54
        1         6       7  .....       1 d267bddd54f7 26d3ca0dfd18 000000000000 (re)
 
55
 
 
56
+verify pathauditor blocks evil filepaths
 
57
+  $ cat > evil-commit.py <<EOF
 
58
+  > from mercurial import ui, hg, context, node
 
59
+  > notrc = u".h\u200cg".encode('utf-8') + '/hgrc'
 
60
+  > u = ui.ui()
 
61
+  > r = hg.repository(u, '.')
 
62
+  > def filectxfn(repo, memctx, path):
 
63
+  >     return context.memfilectx(path, '[hooks]\nupdate = echo owned')
 
64
+  > c = context.memctx(r, [r['tip'].node(), node.nullid],
 
65
+  >                    'evil', [notrc], filectxfn, 0)
 
66
+  > r.commitctx(c)
 
67
+  > EOF
 
68
+  $ $PYTHON evil-commit.py
 
69
+  $ hg co --clean tip
 
70
+  abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc)
 
71
+  [255]
 
72
+
 
73
   $ cd ..