From abc6adaa84c9c4a087722314be63e3f1c33c9901 Mon Sep 17 00:00:00 2001 From: Arvind Date: Thu, 27 Apr 2023 16:58:53 -0700 Subject: [PATCH] Use NamedTemporaryFile to create a temporary file instead of mktemp --- archr/analyzers/qemu_tracer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/archr/analyzers/qemu_tracer.py b/archr/analyzers/qemu_tracer.py index a57ed8d..3dc1c34 100644 --- a/archr/analyzers/qemu_tracer.py +++ b/archr/analyzers/qemu_tracer.py @@ -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: @@ -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: