Unverified Commit 35fc06eb authored by Yuting Jiang's avatar Yuting Jiang Committed by GitHub
Browse files

Bug: Fix code insecure issue that binds a socket to all network interfaces (#291)

**Description**
Fix code insecure issue that binds a socket to all network interfaces.
parent 380ce400
...@@ -16,7 +16,7 @@ def get_free_port(): ...@@ -16,7 +16,7 @@ def get_free_port():
""" """
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try: try:
s.bind(('', 0)) s.bind(('127.0.0.1', 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
return s.getsockname()[1] return s.getsockname()[1]
except OSError: except OSError:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment