Skip to content

Commit

Permalink
Fix crash on zero byte files with non-ascii name (#88)
Browse files Browse the repository at this point in the history
* Fix crash when writing error for zero bytes in files with non-ascii names

* Use string concatenation instead of format to build error msg
  • Loading branch information
OskarPersson authored and Hwesta committed Jan 2, 2017
1 parent bfba927 commit 37928a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fido/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def identify_file(self, filename):
size = os.stat(filename)[6]
self.current_filesize = size
if self.current_filesize == 0:
sys.stderr.write("FIDO: Zero byte file (empty): Path is: {0}\n".format(filename))
sys.stderr.write("FIDO: Zero byte file (empty): Path is: " + filename + "\n")
bofbuffer, eofbuffer, _ = self.get_buffers(f, size, seekable=True)
matches = self.match_formats(bofbuffer, eofbuffer)
container_type = self.container_type(matches)
Expand Down Expand Up @@ -597,7 +597,7 @@ def walk_zip(self, filename, fileobj=None):
self.current_file = item_name
self.current_filesize = item.file_size
if self.current_filesize == 0:
sys.stderr.write("FIDO: Zero byte file (empty): Path is: {0}\n".format(item_name))
sys.stderr.write("FIDO: Zero byte file (empty): Path is: " + item_name + "\n")
bofbuffer, eofbuffer, _ = self.get_buffers(f, item.file_size)
matches = self.match_formats(bofbuffer, eofbuffer)
if len(matches) > 0 and self.current_filesize > 0:
Expand Down

0 comments on commit 37928a0

Please sign in to comment.