Skip to content

Commit 819c64f

Browse files
committed
remove a mktemp use to avoid security scanner noise
1 parent 480edc1 commit 819c64f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/multiprocessing/connection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import sys
1717
import socket
1818
import struct
19-
import tempfile
2019
import time
2120

2221

@@ -77,7 +76,11 @@ def arbitrary_address(family):
7776
if family == 'AF_INET':
7877
return ('localhost', 0)
7978
elif family == 'AF_UNIX':
80-
return tempfile.mktemp(prefix='sock-', dir=util.get_temp_dir())
79+
# NOTE: util.get_temp_dir() is a 0o700 per-process directory. A
80+
# mktemp-style ToC vs ToU concern is not important; bind() surfaces
81+
# the extremely unlikely collision as EADDRINUSE.
82+
return os.path.join(util.get_temp_dir(),
83+
f'sock-{os.urandom(6).hex()}')
8184
elif family == 'AF_PIPE':
8285
return (r'\\.\pipe\pyc-%d-%d-%s' %
8386
(os.getpid(), next(_mmap_counter), os.urandom(8).hex()))

0 commit comments

Comments
 (0)