diff options
author | Tony Cook <tony@develop-help.com> | 2016-08-15 10:39:22 +1000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2016-09-06 10:41:43 +1000 |
commit | 5b549d1d2267bb0d85424c02f9b4c895ebbcf404 (patch) | |
tree | 936f1d754d2df33b3de8c279a75b04cb5a661e22 /dist/IO/t | |
parent | 05bda26ce45ab1f7024d0e8a656a251a181f0275 (diff) | |
download | perl-5b549d1d2267bb0d85424c02f9b4c895ebbcf404.tar.gz |
(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.
Diffstat (limited to 'dist/IO/t')
-rw-r--r-- | dist/IO/t/cachepropagate-unix.t | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/dist/IO/t/cachepropagate-unix.t b/dist/IO/t/cachepropagate-unix.t index e3e438ea1c..20c70dd86a 100644 --- a/dist/IO/t/cachepropagate-unix.t +++ b/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, |