Skip to content

Commit

Permalink
Correct exception handling. Fixes #50
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazza committed May 29, 2019
1 parent 94f716d commit 18090ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions recuperabit/fs/ntfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,8 @@ def parse_indx_record(entry):
entry[offset + 16:],
attr_types_fmt['$FILE_NAME']
)
except UnicodeDecodeError: # Invalid file name
pass
except TypeError: # Invalid name length
pass
except (UnicodeDecodeError, TypeError): # Invalid file name or invalid name length
break
# Perform checks to avoid false positives
name_ok = file_name['name'] is not None
namespace_ok = 0 <= file_name['namespace'] <= 3
Expand Down
2 changes: 1 addition & 1 deletion recuperabit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def sectors(image, offset, size, bsize=sector_size, fill=True):
if read:
try:
dump = image.read(size * bsize)
except IOError, MemoryError:
except (IOError, MemoryError):
logging.warning(
"Cannot read sector(s). Filling with 0x00. Offset: {} Size: "
"{} Bsize: {}".format(offset, size, bsize)
Expand Down

0 comments on commit 18090ab

Please sign in to comment.