From 8e66eb92371d99796516bd7879d56bd6f6a2c0a9 Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Fri, 16 Feb 2024 02:50:21 -0700 Subject: [PATCH] testscript: fix ptyName() returning /dev/pts/4294967296 on s390x Use uint32 instead of uint (64-bit in Go on s390x) to store the return value of the TIOCGPTN syscall. This is to avoid the 32-bit value from being stored into a 64-bit buffer and get left-shifted by 32 when dereferencing, turning what should be /dev/pts/1 to /dev/pts/4294967296 on big-endian architectures such as s390x. Special thanks to the explanation and a similar bug fix provided at https://github.com/containerd/console/pull/51 --- testscript/internal/pty/pty_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testscript/internal/pty/pty_linux.go b/testscript/internal/pty/pty_linux.go index 6e77b3a2..1839218b 100644 --- a/testscript/internal/pty/pty_linux.go +++ b/testscript/internal/pty/pty_linux.go @@ -8,7 +8,7 @@ import ( ) func ptyName(f *os.File) (string, error) { - var out uint + var out uint32 err := ioctl(f, "TIOCGPTN", syscall.TIOCGPTN, uintptr(unsafe.Pointer(&out))) if err != nil { return "", err