This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Revert "Upgrade Socket to CPAN version 2.008"
[perl5.git] / cpan / Socket / Socket.xs
index 0690435..4bfaada 100644 (file)
@@ -895,7 +895,7 @@ inet_ntop(af, ip_address_sv)
        SV *    ip_address_sv
        CODE:
 #ifdef HAS_INETNTOP
        SV *    ip_address_sv
        CODE:
 #ifdef HAS_INETNTOP
-       STRLEN addrlen;
+       STRLEN addrlen, struct_size;
 #ifdef AF_INET6
        struct in6_addr addr;
        char str[INET6_ADDRSTRLEN];
 #ifdef AF_INET6
        struct in6_addr addr;
        char str[INET6_ADDRSTRLEN];
@@ -910,17 +910,19 @@ inet_ntop(af, ip_address_sv)
 
        ip_address = SvPV(ip_address_sv, addrlen);
 
 
        ip_address = SvPV(ip_address_sv, addrlen);
 
+       struct_size = sizeof(addr);
+
        switch(af) {
          case AF_INET:
            if(addrlen != 4)
                croak("Bad address length for Socket::inet_ntop on AF_INET;"
        switch(af) {
          case AF_INET:
            if(addrlen != 4)
                croak("Bad address length for Socket::inet_ntop on AF_INET;"
-                     " got %"UVuf", should be 4", (UV)addrlen);
+                     " got %d, should be 4", addrlen);
            break;
 #ifdef AF_INET6
          case AF_INET6:
            if(addrlen != 16)
                croak("Bad address length for Socket::inet_ntop on AF_INET6;"
            break;
 #ifdef AF_INET6
          case AF_INET6:
            if(addrlen != 16)
                croak("Bad address length for Socket::inet_ntop on AF_INET6;"
-                     " got %"UVuf", should be 16", (UV)addrlen);
+                     " got %d, should be 16", addrlen);
            break;
 #endif
          default:
            break;
 #endif
          default:
@@ -933,13 +935,7 @@ inet_ntop(af, ip_address_sv)
                      "Socket::inet_ntop", af);
        }
 
                      "Socket::inet_ntop", af);
        }
 
-       if(addrlen < sizeof(addr)) {
-           Copy(ip_address, &addr, addrlen, char);
-           Zero(((char*)&addr) + addrlen, sizeof(addr) - addrlen, char);
-       }
-       else {
-           Copy(ip_address, &addr, sizeof addr, char);
-       }
+       Copy(ip_address, &addr, sizeof addr, char);
        inet_ntop(af, &addr, str, sizeof str);
 
        ST(0) = sv_2mortal(newSVpvn(str, strlen(str)));
        inet_ntop(af, &addr, str, sizeof str);
 
        ST(0) = sv_2mortal(newSVpvn(str, strlen(str)));