From 4b09738d6af9f9ed8890fd7af0868339e4a3fda9 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
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
a
|
b
|
use Test::More; |
14 | 14 | plan skip_all => "UNIX domain sockets not implemented on $^O" |
15 | 15 | if ($^O =~ m/^(?:qnx|nto|vos|MSWin32|VMS)$/); |
16 | 16 | |
17 | | plan tests => 15; |
18 | | |
19 | 17 | my $socketpath = catfile(tempdir( CLEANUP => 1 ), 'testsock'); |
20 | 18 | |
| 19 | # check the socketpath fits in sun_path. |
| 20 | # |
| 21 | # pack_sockaddr_un() just truncates the path, this may change, but how |
| 22 | # it will handle such a condition is undetermined (and we might need |
| 23 | # to work with older versions of Socket outside of a perl build) |
| 24 | # https://rt.cpan.org/Ticket/Display.html?id=116819 |
| 25 | |
| 26 | my $name = eval { pack_sockaddr_un($socketpath) }; |
| 27 | defined $name && (unpack_sockaddr_un($name))[0] eq $socketpath |
| 28 | or plan skip_all => "socketpath too long for sockaddr_un"; |
| 29 | |
| 30 | plan tests => 15; |
| 31 | |
21 | 32 | # start testing stream sockets: |
22 | 33 | my $listener = IO::Socket::UNIX->new(Type => SOCK_STREAM, |
23 | 34 | Listen => 1, |