Skip to content

Commit

Permalink
Fix hexdump_iter for actual file objects, like those used by phd
Browse files Browse the repository at this point in the history
  • Loading branch information
zachriggle committed Jan 11, 2017
1 parent 975844d commit f46112e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pwnlib/util/fiddling.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import base64
import random
import os
import re
import string
import StringIO
Expand Down Expand Up @@ -617,14 +618,15 @@ def hexdump_iter(fd, width=16, skip=True, hexii=False, begin=0, style=None,
total = fd.len
else:
# Save the current file offset
cur = fd.seek(0, os.SEEK_CUR)
cur = fd.tell()

# Determine the total size of the file
fd.seek(0, os.SEEK_END)
total = fd.tell()
total = fd.tell() - cur

# Restore the file offset, and
fd.seek(cur or 0, os.SEEK_SET)

# Restore the file offset
fd.seek(cur, os.SEEK_SET)

if hexii:
column_sep = ''
Expand Down

0 comments on commit f46112e

Please sign in to comment.