Browse Source

PR #245 - Merge branch 'fix_exceptions' into merge

Conflicts:
	attic/archive.py
Thomas Waldmann 10 years ago
parent
commit
dd8ff50a5c
2 changed files with 4 additions and 2 deletions
  1. 3 1
      attic/archive.py
  2. 1 1
      attic/repository.py

+ 3 - 1
attic/archive.py

@@ -613,7 +613,9 @@ class ArchiveChecker:
                 continue
                 continue
             try:
             try:
                 archive = msgpack.unpackb(data)
                 archive = msgpack.unpackb(data)
-            except Exception:
+            # Ignore exceptions that might be raised when feeding
+            # msgpack with invalid data
+            except (TypeError, ValueError, StopIteration):
                 continue
                 continue
             if isinstance(archive, dict) and b'items' in archive and b'cmdline' in archive:
             if isinstance(archive, dict) and b'items' in archive and b'cmdline' in archive:
                 self.report_progress('Found archive ' + archive[b'name'].decode('utf-8'), error=True)
                 self.report_progress('Found archive ' + archive[b'name'].decode('utf-8'), error=True)

+ 1 - 1
attic/repository.py

@@ -446,7 +446,7 @@ class LoggedIO:
         with open(filename, 'rb') as fd:
         with open(filename, 'rb') as fd:
             try:
             try:
                 fd.seek(-self.header_fmt.size, os.SEEK_END)
                 fd.seek(-self.header_fmt.size, os.SEEK_END)
-            except Exception as e:
+            except OSError as e:
                 # return False if segment file is empty or too small
                 # return False if segment file is empty or too small
                 if e.errno == errno.EINVAL:
                 if e.errno == errno.EINVAL:
                     return False
                     return False