{
#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");
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",
"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