]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests/scripts/common.sh: avoid IPv6 in check_if_port_*
authorAlexander Sosedkin <asosedkin@redhat.com>
Tue, 20 Jan 2026 00:34:05 +0000 (01:34 +0100)
committerAlexander Sosedkin <asosedki@redhat.com>
Wed, 28 Jan 2026 11:44:07 +0000 (11:44 +0000)
I've encountered a race condition when IPv4 couldn't bind, IPv6 did bind,
the check passed because IPv6 could bind,
but then tlsfuzzer testsuite used IPv4 and failed.
One of the simplest solutions is to filter out IPv6 in the checks.

Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
tests/scripts/common.sh

index 0f68b02fb9d91baacd62e93ed40dc99fc6513eff..1b78b8cf10591346b84d38b2be676a6c33f9f675 100644 (file)
@@ -70,7 +70,7 @@ check_if_port_in_use() {
        local PORT=$1
        reserve_port $PORT
        have_port_finder
-       if ! $PFCMD -an|grep "[\:\.]$PORT" >/dev/null 2>&1; then
+       if ! $PFCMD -an|grep -v ::|grep "[\:\.]$PORT" >/dev/null 2>&1; then
                return 1
        fi
        unreserve_port $PORT
@@ -79,7 +79,7 @@ check_if_port_in_use() {
 check_if_port_listening() {
        local PORT=$1
        have_port_finder
-       $PFCMD -anl|grep "[\:\.]$PORT"|grep LISTEN >/dev/null 2>&1
+       $PFCMD -anl|grep -v ::|grep "[\:\.]$PORT"|grep LISTEN >/dev/null 2>&1
 }
 
 # Find a port number not currently in use.