Skip to content

Commit b13f56b

Browse files
committed
Create temporary copy of cached file
1 parent 4c42d77 commit b13f56b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pwnlib/asm.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,13 @@ def asm(shellcode, vma = 0, extract = True, shared = False):
783783
if extract:
784784
with open(cache_file, 'rb') as f:
785785
return f.read()
786-
else:
787-
return cache_file
786+
787+
# Create a temporary copy of the cached file to avoid modification.
788+
tmpdir = tempfile.mkdtemp(prefix = 'pwn-asm-')
789+
atexit.register(shutil.rmtree, tmpdir)
790+
step3 = os.path.join(tmpdir, 'step3')
791+
shutil.copy(cache_file, step3)
792+
return step3
788793

789794
assembler = _assembler()
790795
linker = _linker()

0 commit comments

Comments
 (0)