In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/6aba156ffbafbf27a3ba4f313d90ed712fc4e5d4?hp=00ebc5bdc54d3943d2470f1053942f5849ab1a9d>
- Log ----------------------------------------------------------------- commit 6aba156ffbafbf27a3ba4f313d90ed712fc4e5d4 Author: Steve Hay <[email protected]> Date: Sat Oct 17 22:22:55 2015 +0100 Book-keeping for the previous commit (which restored the VC6 build, btw) M Porting/Maintainers.pl M cpan/Socket/Socket.pm M t/porting/customized.dat commit e45189ae472830e78ec678c4bd0c35cbe52b10f8 Author: Daniel Dragan <[email protected]> Date: Thu Sep 10 03:36:36 2015 -0400 Win32 inet_pton fallback misc fixes -VC complains in inet_pton "warning C4715: 'inet_pton' : not all control paths return a value" this isn't much a problem since Socket.xs doesn't allow anything but AF_INET and AF_INET6 on a XSUB level but fix the implementation anyway since the previous cargo culted off the internet version has flaws, so the Socket.xs version is usable elsewhere if necessery -remove copying the string to C auto array, unix inet_ptoa requires null terminated strings, so does WSAStringToAddress. WSAStringToAddress's docs dont mention a maximum length to the input string, so no reason to truncate and re-null terminate it -MSDN's docs for WSAStringToAddress mentions that filling in sin_family is required, even though lpAddress is an output arg, not input and a duplicate of arg AddressFamily, there is probably some legacy protocol driver out in the world that requires this -static the functions, these fallbacks dont need to be visible in any other .o, and with static they might be inlined/further optimized -provide fallbacks for Visual C 6 (circa 1998) with very old headers that were created before RFC 2553 was created M cpan/Socket/Socket.xs ----------------------------------------------------------------------- Summary of changes: Porting/Maintainers.pl | 1 + cpan/Socket/Socket.pm | 2 +- cpan/Socket/Socket.xs | 43 ++++++++++++++++++++++++++++++++++--------- t/porting/customized.dat | 4 ++-- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index 03ee992..43b48e7 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -1004,6 +1004,7 @@ use File::Glob qw(:case); 'FILES' => q[cpan/Socket], # https://rt.cpan.org/Ticket/Display.html?id=106797 + # https://rt.cpan.org/Ticket/Display.html?id=107058 'CUSTOMIZED' => [ qw[ Socket.pm Socket.xs ] ], }, diff --git a/cpan/Socket/Socket.pm b/cpan/Socket/Socket.pm index cd572af..dd89450 100644 --- a/cpan/Socket/Socket.pm +++ b/cpan/Socket/Socket.pm @@ -3,7 +3,7 @@ package Socket; use strict; { use 5.006001; } -our $VERSION = '2.020_01'; # patched in perl5.git +our $VERSION = '2.020_02'; # patched in perl5.git =head1 NAME diff --git a/cpan/Socket/Socket.xs b/cpan/Socket/Socket.xs index 5f60afa..52df483 100644 --- a/cpan/Socket/Socket.xs +++ b/cpan/Socket/Socket.xs @@ -52,18 +52,40 @@ #endif #ifdef WIN32 -int inet_pton(int af, const char *src, void *dst) + +/* VC 6 with its original headers doesn't know about sockaddr_storage, VC 2003 does*/ +#ifndef _SS_MAXSIZE + +# define _SS_MAXSIZE 128 +# define _SS_ALIGNSIZE (sizeof(__int64)) + +# define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (short)) +# define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (short) + _SS_PAD1SIZE \ + + _SS_ALIGNSIZE)) + +struct sockaddr_storage { + short ss_family; + char __ss_pad1[_SS_PAD1SIZE]; + __int64 __ss_align; + char __ss_pad2[_SS_PAD2SIZE]; +}; + +typedef int socklen_t; + +#define in6_addr in_addr6 + +#define INET_ADDRSTRLEN 22 +#define INET6_ADDRSTRLEN 65 + +#endif + +static int inet_pton(int af, const char *src, void *dst) { struct sockaddr_storage ss; int size = sizeof(ss); - char src_copy[INET6_ADDRSTRLEN+1]; + ss.ss_family = af; /* per MSDN */ - ZeroMemory(&ss, sizeof(ss)); - /* stupid non-const API */ - strncpy(src_copy, src, INET6_ADDRSTRLEN+1); - src_copy[INET6_ADDRSTRLEN] = 0; - - if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) != 0) + if (WSAStringToAddress((char*)src, af, NULL, (struct sockaddr *)&ss, &size) != 0) return 0; switch(af) { @@ -73,10 +95,13 @@ int inet_pton(int af, const char *src, void *dst) case AF_INET6: *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr; return 1; + default: + WSASetLastError(WSAEAFNOSUPPORT); + return -1; } } -const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) +static const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) { struct sockaddr_storage ss; unsigned long s = size; diff --git a/t/porting/customized.dat b/t/porting/customized.dat index 987f92e..da4a0f1 100644 --- a/t/porting/customized.dat +++ b/t/porting/customized.dat @@ -21,8 +21,8 @@ Scalar-List-Utils cpan/Scalar-List-Utils/lib/List/Util/XS.pm 08abbe1a707927cee53 Scalar-List-Utils cpan/Scalar-List-Utils/lib/Scalar/Util.pm 7f1e6eb11105623200ef9cdcb881545ccb769ded Scalar-List-Utils cpan/Scalar-List-Utils/lib/Sub/Util.pm d87811528ae3587f04e2f09894b8c88471754386 Scalar-List-Utils cpan/Scalar-List-Utils/ListUtil.xs ed25abc419771d6f3f12323f1f0a372f043d51b2 -Socket cpan/Socket/Socket.pm f5d4a196fe9376d4ec8c09da318e348cbf1e2ab5 -Socket cpan/Socket/Socket.xs ae3f68904b11389da5442319cb15918b629d86b4 +Socket cpan/Socket/Socket.pm bdc42a2bd5cb560ed1120a3e6f408ed7ece14dce +Socket cpan/Socket/Socket.xs 6102315291684e56e360ff5e0dd237c9394c49b8 Text::ParseWords cpan/Text-ParseWords/t/ParseWords.t 9bae51c9b944cd5c0bbabe9d397e573976a2be8e Win32API::File cpan/Win32API-File/buffers.h 02d230ac9ac7091365128161a0ed671898baefae Win32API::File cpan/Win32API-File/cFile.h fca7e383e76979c3ac3adf12d11d1bcd2618e489 -- Perl5 Master Repository
