From e85fa7ee5acde8406f9e05f451d08ab578bc25cf Mon Sep 17 00:00:00 2001 From: "nbarth@chromium.org" Date: Wed, 23 Apr 2014 08:09:48 +0000 Subject: 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 --- tools/checkdeps/checkdeps.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'tools/checkdeps/checkdeps.py') 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: -- cgit v1.1