]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix infinite loop in should_ignore_path for absolute paths.
authorDaira Hopwood <daira@jacaranda.org>
Thu, 22 Oct 2015 13:28:26 +0000 (14:28 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 28 Dec 2015 16:18:53 +0000 (16:18 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/magicpath.py

index ba15ed581bdd455af7ea0e87edf9f68dfbbf1ed7..53e669b6358b50bb07ca2b5a59888747ed708cb0 100644 (file)
@@ -2,7 +2,7 @@
 import re
 import os.path
 
-from allmydata.util.assertutil import precondition
+from allmydata.util.assertutil import precondition, _assert
 
 def path2magic(path):
     return re.sub(ur'[/@]',  lambda m: {u'/': u'@_', u'@': u'@@'}[m.group(0)], path)
@@ -20,8 +20,14 @@ def should_ignore_file(path_u):
     for suffix in IGNORE_SUFFIXES:
         if path_u.endswith(suffix):
             return True
+
     while path_u != u"":
+        oldpath_u = path_u
         path_u, tail_u = os.path.split(path_u)
         if tail_u.startswith(u"."):
             return True
+        if path_u == oldpath_u:
+            return True  # the path was absolute
+        _assert(len(path_u) < len(oldpath_u), path_u=path_u, oldpath_u=oldpath_u)
+
     return False