~ubuntu-branches/ubuntu/precise/mercurial/precise-security

« back to all changes in this revision

Viewing changes to mercurial/scmutil.py

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers, Jamie Strandboge, Marc Deslauriers
  • Date: 2015-06-17 13:27:17 UTC
  • Revision ID: package-import@ubuntu.com-20150617132717-jnkpv615dwh5bzox
Tags: 2.0.2-1ubuntu1.2
[ 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/sshrepo.py.
  - CVE-2014-9462

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
# This software may be used and distributed according to the terms of the
6
6
# GNU General Public License version 2 or any later version.
7
7
 
 
8
import encoding
8
9
from i18n import _
9
10
import util, error, osutil, revset, similar, encoding
10
11
import match as matchmod
11
12
import os, errno, re, stat, sys, glob
12
13
 
 
14
def _lowerclean(s):
 
15
    return encoding.hfsignoreclean(s.lower())
 
16
 
13
17
def checkfilename(f):
14
18
    '''Check that the filename f is an acceptable filename for a tracked file'''
15
19
    if '\r' in f or '\n' in f:
94
98
            raise util.Abort(_("path ends in directory separator: %s") % path)
95
99
        parts = util.splitpath(path)
96
100
        if (os.path.splitdrive(path)[0]
97
 
            or parts[0].lower() in ('.hg', '.hg.', '')
 
101
            or _lowerclean(parts[0]) in ('.hg', '.hg.', '')
98
102
            or os.pardir in parts):
99
103
            raise util.Abort(_("path contains illegal component: %s") % path)
100
 
        if '.hg' in path.lower():
101
 
            lparts = [p.lower() for p in parts]
 
104
        # Windows shortname aliases
 
105
        for p in parts:
 
106
            if "~" in p:
 
107
                first, last = p.split("~", 1)
 
108
                if last.isdigit() and first.upper() in ["HG", "HG8B6C"]:
 
109
                    raise util.Abort(_("path contains illegal component: %s")
 
110
                                     % path)
 
111
        if '.hg' in _lowerclean(path):
 
112
            lparts = [_lowerclean(p.lower()) for p in parts]
102
113
            for p in '.hg', '.hg.':
103
114
                if p in lparts[1:]:
104
115
                    pos = lparts.index(p)