summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2010-12-10 15:02:30 +0000
committerJesse Vincent <jesse@bestpractical.com>2011-01-03 12:21:34 +0800
commit5897b17c4d70117f94844ce8c121778e577c1406 (patch)
tree7bdd85e29c46260bc6a343935e06693e11066476 /ext
parentf52c37b45fe0cf91d5a5c7d022a895b84edc08dc (diff)
downloadperl-5897b17c4d70117f94844ce8c121778e577c1406.tar.gz
Conditionally set sa_len-type fields when packing sockaddr addresses
Diffstat (limited to 'ext')
-rw-r--r--ext/Socket/Socket.xs9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs
index c1225ffc1d..ff1fa7a77f 100644
--- a/ext/Socket/Socket.xs
+++ b/ext/Socket/Socket.xs
@@ -343,6 +343,9 @@ pack_sockaddr_un(pathname)
} else {
addr_len = sizeof sun_ad;
}
+# ifdef HAS_SOCKADDR_SA_LEN
+ sun_ad.sun_len = addr_len;
+# endif
ST(0) = newSVpvn_flags((char *)&sun_ad, addr_len, SVs_TEMP);
#else
ST(0) = (SV *) not_here("pack_sockaddr_un");
@@ -421,6 +424,9 @@ pack_sockaddr_in(port, ip_address_sv)
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
sin.sin_addr.s_addr = htonl(addr.s_addr);
+# ifdef HAS_SOCKADDR_SA_LEN
+ sin.sin_len = sizeof (sin);
+# endif
ST(0) = newSVpvn_flags((char *)&sin, sizeof (sin), SVs_TEMP);
}
@@ -480,6 +486,9 @@ pack_sockaddr_in6(port, sin6_addr, scope_id=0, flowinfo=0)
#if !defined(__GLIBC__) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
sin6.sin6_scope_id = scope_id;
#endif
+# ifdef HAS_SOCKADDR_SA_LEN
+ sin6.sin6_len = sizeof(sin6);
+# endif
ST(0) = newSVpvn_flags((char *)&sin6, sizeof(sin6), SVs_TEMP);
#else
ST(0) = (SV*)not_here("pack_sockaddr_in6");