Skip to content

Commit

Permalink
Merge pull request #138 from angr/fix/fix-file-leak-in-qemu-tracer
Browse files Browse the repository at this point in the history
Fix file leak in QEMU tracer
  • Loading branch information
Kyle-Kyle authored Jul 21, 2023
2 parents fafe677 + abc6ada commit 3e0100f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions archr/analyzers/qemu_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ def fire_context(
r.halfway_core_path = local_halfway_core_filename

if target_trace_filename:
temp_trace_file = tempfile.mktemp(dir="/tmp", prefix="tracer-")
self.target.copy_file(target_trace_filename, temp_trace_file)
trace_fh = open(temp_trace_file, "rb")
temp_trace_file = tempfile.NamedTemporaryFile()
self.target.copy_file(target_trace_filename, temp_trace_file.name)
trace_fh = open(temp_trace_file.name, "rb")

# Find where qemu loaded the binary. Primarily for PIE
try:
Expand Down Expand Up @@ -303,6 +303,8 @@ def fire_context(

lastline = entry
bbl_trace_fh.close()
trace_fh.close()
temp_trace_file.close()
r.trace = QEMUBBLTrace(bbl_trace_file.name, bbl_trace_len)

if r.crashed:
Expand Down

0 comments on commit 3e0100f

Please sign in to comment.