Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
corna committed Aug 29, 2017
1 parent 2e8761e commit 5ffeaff
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions me_cleaner.py
Expand Up @@ -74,7 +74,7 @@ def move_range(self, offset_from, size, offset_to, fill):
offset_to + size <= self.region_end:
for i in range(0, size, 4096):
self.f.seek(offset_from + i, 0)
block = self.f.read(4096 if size - i >= 4096 else size - i)
block = self.f.read(min(size - i, 4096))
self.f.seek(offset_from + i, 0)
self.f.write(fill * len(block))
self.f.seek(offset_to + i, 0)
Expand All @@ -86,7 +86,7 @@ def save(self, filename, size):
self.f.seek(self.region_start)
copyf = open(filename, "w+b")
for i in range(0, size, 4096):
copyf.write(self.f.read(4096 if size - i >= 4096 else size - i))
copyf.write(self.f.read(min(size - i, 4096)))
return copyf


Expand Down Expand Up @@ -678,12 +678,12 @@ def start_end_to_flreg(start, end):
"isn't equal to the end address of the ME\n region: if "
"you want to recover the space from the ME region you "
"have to\n manually modify the descriptor.\n")

fdf_copy.close()
else:
print("Extracting the descriptor to \"{}\"..."
.format(args.extract_descriptor))
fdf.save(args.extract_descriptor, fd_end - fd_start).close()
fdf_copy = fdf.save(args.extract_descriptor, fd_end - fd_start)

fdf_copy.close()

if args.extract_me:
if args.truncate:
Expand Down

0 comments on commit 5ffeaff

Please sign in to comment.