Lazza / RecuperaBit

A tool for forensic file system reconstruction.
GNU General Public License v3.0
534 stars 75 forks source link

Fix type error when adding padded bytes. #90

Closed rober710 closed 3 years ago

rober710 commented 3 years ago

During recovery of one of the partitions, I got the following error:

WARNING:root:Failed to read byte(s). Padding with 0x00. Offset: 113928912896 Size: 131072
Traceback (most recent call last):
  File "main.py", line 401, in <module>
    main()
  File "main.py", line 398, in main
    interpret(cmd, arguments, parts, shorthands, args.outputdir)
  File "main.py", line 257, in interpret
    restore_part(i, parts, shorthands, -1, outdir)
  File "main.py", line 278, in restore_part
    logic.recursive_restore(myfile, part, partition_dir)
  File "/home/Rober/Programas/RecuperaBit/recuperabit/logic.py", line 259, in recursive_restore
    recursive_restore(child, part, outputdir, make_dirs=False)
  File "/home/Rober/Programas/RecuperaBit/recuperabit/logic.py", line 259, in recursive_restore
    recursive_restore(child, part, outputdir, make_dirs=False)
  File "/home/Rober/Programas/RecuperaBit/recuperabit/logic.py", line 259, in recursive_restore
    recursive_restore(child, part, outputdir, make_dirs=False)
  [Previous line repeated 1 more time]
  File "/home/Rober/Programas/RecuperaBit/recuperabit/logic.py", line 245, in recursive_restore
    for piece in content:
  File "/home/Rober/Programas/RecuperaBit/recuperabit/fs/ntfs.py", line 366, in content_iterator
    partial = self._padded_bytes(image, position, amount)
  File "/home/Rober/Programas/RecuperaBit/recuperabit/fs/ntfs.py", line 322, in _padded_bytes
    dump += bytearray('\x00' * (size - len(dump)))
TypeError: string argument without an encoding

This PR just prefixes the string with b to convert it to a bytes instance instead of str, so that the function doesn't require an encoding.

Lazza commented 3 years ago

Sorry that I left this opened a bit too much. Thanks for your contribution!