Skip Menu |

This queue is for tickets about the Socket CPAN distribution.

Report information
The Basics
Id: 75074
Status: resolved
Priority: 0/
Queue: Socket

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.98
Fixed in:
  • 1.98_001
  • 1.99



Subject: inet_pton() returns overly-long result for AF_INET
$ perl -MSocket=AF_INET,inet_pton -E 'say length inet_pton( AF_INET, "127.0.0.1" )' 16 $ perl -MSocket=inet_aton -E 'say length inet_aton( "127.0.0.1" )' 4 -- Paul Evans
Attached is a patch to fix it. Will be in 1.99 along with some more robust testing that would have detected this one. -- Paul Evans
Subject: rt75074.patch
=== modified file 'Socket.xs' --- Socket.xs 2012-02-12 11:37:51 +0000 +++ Socket.xs 2012-02-16 23:33:47 +0000 @@ -912,17 +912,23 @@ CODE: #ifdef HAS_INETPTON int ok; + int addrlen = 0; #ifdef AF_INET6 struct in6_addr ip_address; #else struct in_addr ip_address; #endif - if (af != AF_INET + switch(af) { + case AF_INET: + addrlen = 4; + break; #ifdef AF_INET6 - && af != AF_INET6 + case AF_INET6: + addrlen = 16; + break; #endif - ) { + default: croak("Bad address family for %s, got %d, should be" #ifdef AF_INET6 " either AF_INET or AF_INET6", @@ -935,7 +941,7 @@ ST(0) = sv_newmortal(); if (ok) { - sv_setpvn( ST(0), (char *)&ip_address, sizeof(ip_address) ); + sv_setpvn( ST(0), (char *)&ip_address, addrlen); } #else ST(0) = (SV*)not_here("inet_pton");
On Thu Feb 16 18:34:52 2012, PEVANS wrote: Show quoted text
> Attached is a patch to fix it. > > Will be in 1.99 along with some more robust testing that would have > detected this one.
Now CPANned as 1.98_001. -- Paul Evans
Released as 1.99 -- Paul Evans