summaryrefslogtreecommitdiffstats
path: root/tools/checkdeps/checkdeps.py
diff options
context:
space:
mode:
authornbarth@chromium.org <nbarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 08:09:48 +0000
committernbarth@chromium.org <nbarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 08:09:48 +0000
commite85fa7ee5acde8406f9e05f451d08ab578bc25cf (patch)
treef841605fb6bb83c2721d2fcfcfd375377c0b8eca /tools/checkdeps/checkdeps.py
parente6222ba4d2cadf0fc498a3a55ca62a17ed012551 (diff)
downloadchromium_src-e85fa7ee5acde8406f9e05f451d08ab578bc25cf.zip
chromium_src-e85fa7ee5acde8406f9e05f451d08ab578bc25cf.tar.gz
chromium_src-e85fa7ee5acde8406f9e05f451d08ab578bc25cf.tar.bz2
Fix relative/absolute path handling in checkdeps.py
Currently checkdeps.py fails if you specify a start dir and a *relative* path for root, such as: tools/checkdeps/checkdeps.py --root third_party/WebKit Source/bindings (Exact error is a stack overflow, due to infinite recursion on /) This is because it makes the start dir absolute, but doesn't make the root dir absolute. Simple fix, by making the root dir absolute. Also checks that directory to check is actually a subdirectory of root, which otherwise has the same stack overflow error. R=joi BUG=365190 Review URL: https://codereview.chromium.org/244673002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/checkdeps/checkdeps.py')
-rwxr-xr-xtools/checkdeps/checkdeps.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/checkdeps/checkdeps.py b/tools/checkdeps/checkdeps.py
index 3789b0e..6e815c0 100755
--- a/tools/checkdeps/checkdeps.py
+++ b/tools/checkdeps/checkdeps.py
@@ -195,21 +195,26 @@ def main():
verbose=options.verbose,
ignore_temp_rules=options.ignore_temp_rules,
skip_tests=options.skip_tests)
+ base_directory = deps_checker.base_directory # Default if needed, normalized
# Figure out which directory we have to check.
- start_dir = deps_checker.base_directory
+ start_dir = base_directory
if len(args) == 1:
# Directory specified. Start here. It's supposed to be relative to the
# base directory.
- start_dir = os.path.abspath(
- os.path.join(deps_checker.base_directory, args[0]))
+ start_dir = os.path.abspath(os.path.join(base_directory, args[0]))
elif len(args) >= 2 or (options.generate_temp_rules and
options.count_violations):
# More than one argument, or incompatible flags, we don't handle this.
PrintUsage()
return 1
- print 'Using base directory:', deps_checker.base_directory
+ if not start_dir.startswith(deps_checker.base_directory):
+ print 'Directory to check must be a subdirectory of the base directory,'
+ print 'but %s is not a subdirectory of %s' % (start_dir, base_directory)
+ return 1
+
+ print 'Using base directory:', base_directory
print 'Checking:', start_dir
if options.generate_temp_rules: