Ticket #51327: 0001-perl-128095-check-pack_sockaddr_un-s-return-value.patch

File 0001-perl-128095-check-pack_sockaddr_un-s-return-value.patch, 1.6 KB (added by mojca (Mojca Miklavec), 8 years ago)
  • dist/IO/t/cachepropagate-unix.t

    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; 
    1414plan skip_all => "UNIX domain sockets not implemented on $^O"
    1515  if ($^O =~ m/^(?:qnx|nto|vos|MSWin32|VMS)$/);
    1616
    17 plan tests => 15;
    18 
    1917my $socketpath = catfile(tempdir( CLEANUP => 1 ), 'testsock');
    2018
     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
     26my $name = eval { pack_sockaddr_un($socketpath) };
     27defined $name && (unpack_sockaddr_un($name))[0] eq $socketpath
     28  or plan skip_all => "socketpath too long for sockaddr_un";
     29
     30plan tests => 15;
     31
    2132# start testing stream sockets:
    2233my $listener = IO::Socket::UNIX->new(Type => SOCK_STREAM,
    2334                                     Listen => 1,