Skip to content

Commit

Permalink
Use NamedTemporaryFile to create a temporary file instead of mktemp
Browse files Browse the repository at this point in the history
  • Loading branch information
dnivra committed Apr 27, 2023
1 parent 8144867 commit 1132e3d
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 @@ -236,9 +236,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 @@ -296,6 +296,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 1132e3d

Please sign in to comment.