From 4b09738d6af9f9ed8890fd7af0868339e4a3fda9 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Mon, 15 Aug 2016 10:39:22 +1000 Subject: (perl #128095) check pack_sockaddr_un()'s return value pack_sockaddr_un() silently truncates the supplied path if it won't fit into the sun_path member of sockaddr_un. This may change in the future, but for now check the path in the sockaddr matches the desired path, and skip if it doesn't. --- dist/IO/t/cachepropagate-unix.t | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dist/IO/t/cachepropagate-unix.t b/dist/IO/t/cachepropagate-unix.t index e3e438e..20c70dd 100644 --- dist/IO/t/cachepropagate-unix.t.orig +++ dist/IO/t/cachepropagate-unix.t @@ -14,10 +14,21 @@ use Test::More; plan skip_all => "UNIX domain sockets not implemented on $^O" if ($^O =~ m/^(?:qnx|nto|vos|MSWin32|VMS)$/); -plan tests => 15; - my $socketpath = catfile(tempdir( CLEANUP => 1 ), 'testsock'); +# check the socketpath fits in sun_path. +# +# pack_sockaddr_un() just truncates the path, this may change, but how +# it will handle such a condition is undetermined (and we might need +# to work with older versions of Socket outside of a perl build) +# https://rt.cpan.org/Ticket/Display.html?id=116819 + +my $name = eval { pack_sockaddr_un($socketpath) }; +defined $name && (unpack_sockaddr_un($name))[0] eq $socketpath + or plan skip_all => "socketpath too long for sockaddr_un"; + +plan tests => 15; + # start testing stream sockets: my $listener = IO::Socket::UNIX->new(Type => SOCK_STREAM, Listen => 1, -- 2.1.4