Skip to content

Commit 0d63a56

Browse files
committed
Fix logic error and mind the sub shell (fd)
1 parent 9e29b35 commit 0d63a56

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

testssl.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,10 +1938,12 @@ http_head_printf() {
19381938

19391939
IFS=/ read -r proto foo node query <<< "$1"
19401940
node=${node%:*}
1941-
# $node works here good as it connects via IPv6 first, then IPv4
1942-
bash -c "exec 33<>/dev/tcp/$node/80" 2>/dev/null &
1941+
# $node works here good as it connects via IPv6 first, then IPv4.
1942+
# This is a subshell, so fd 8 is not inherited
1943+
bash -c "exec 8<>/dev/tcp/$node/80" 2>/dev/null &
19431944
wait_kill $! $HEADER_MAXSLEEP
1944-
if [[ $? -ne 0 ]]; then
1945+
if [[ $? -eq 0 ]]; then
1946+
exec 33<>/dev/tcp/$node/80
19451947
# not killed --> socket open. Now we connect to the virtual host "$node"
19461948
printf -- "%b" "HEAD ${proto}//${node}/${query} HTTP/1.1\r\nUser-Agent: ${useragent}\r\nHost: ${node}\r\n${request_header}\r\nAccept: */*\r\n\r\n\r\n" >&33 2>$errfile
19471949
ret=0

0 commit comments

Comments
 (0)