summaryrefslogtreecommitdiff
path: root/ext/Socket
diff options
context:
space:
mode:
authorTrevor Blackwell <tlb@viaweb.com>1997-10-28 08:04:43 -0500
committerGurusamy Sarathy <gsar@cpan.org>1998-03-03 03:55:13 +0000
commitfcdb74fc457a967c0dbbf004893e223481b9f9ae (patch)
treec6d4e39d328141e5bd8a20d4f52a50051fdaaa69 /ext/Socket
parent2c268ad5f2bec64cb74406f2e1af30ddc0dc3b9f (diff)
downloadperl-fcdb74fc457a967c0dbbf004893e223481b9f9ae.tar.gz
[win32] maintpatch
#60: "Socket occasional SEGV" Msg-ID: <199710281804.NAA09632@wagg.viaweb.com> Files: ext/Socket/Socket.xs p4raw-id: //depot/win32/perl@636
Diffstat (limited to 'ext/Socket')
-rw-r--r--ext/Socket/Socket.xs15
1 files changed, 10 insertions, 5 deletions
diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs
index d37208f012..d2f3d9e10d 100644
--- a/ext/Socket/Socket.xs
+++ b/ext/Socket/Socket.xs
@@ -742,9 +742,10 @@ pack_sockaddr_un(pathname)
{
#ifdef I_SYS_UN
struct sockaddr_un sun_ad; /* fear using sun */
+ STRLEN len;
Zero( &sun_ad, sizeof sun_ad, char );
sun_ad.sun_family = AF_UNIX;
- Copy( pathname, sun_ad.sun_path, sizeof sun_ad.sun_path, char );
+ strncpy(sun_ad.sun_path, pathname, sizeof sun_ad.sun_path);
ST(0) = sv_2mortal(newSVpv((char *)&sun_ad, sizeof sun_ad));
#else
ST(0) = (SV *) not_here("pack_sockaddr_un");
@@ -758,9 +759,10 @@ unpack_sockaddr_un(sun_sv)
CODE:
{
#ifdef I_SYS_UN
- STRLEN sockaddrlen;
struct sockaddr_un addr;
- char * sun_ad = SvPV(sun_sv,sockaddrlen);
+ STRLEN sockaddrlen;
+ char * sun_ad = SvPV(sun_sv,sockaddrlen);
+ char * e;
if (sockaddrlen != sizeof(addr)) {
croak("Bad arg length for %s, length is %d, should be %d",
@@ -775,8 +777,11 @@ unpack_sockaddr_un(sun_sv)
"Socket::unpack_sockaddr_un",
addr.sun_family,
AF_UNIX);
- }
- ST(0) = sv_2mortal(newSVpv(addr.sun_path, strlen(addr.sun_path)));
+ }
+ e = addr.sun_path;
+ while (*e && e < addr.sun_path + sizeof addr.sun_path)
+ ++e;
+ ST(0) = sv_2mortal(newSVpvn(addr.sun_path, e - addr.sun_path));
#else
ST(0) = (SV *) not_here("unpack_sockaddr_un");
#endif