File perl-Socket-MsgHdr.diff of Package perl-Socket-MsgHdr

--- ./MsgHdr.pm.orig	2003-11-12 07:25:10.000000000 +0000
+++ ./MsgHdr.pm	2006-06-01 10:44:08.000000000 +0000
@@ -26,6 +26,10 @@ INIT {
     no strict 'refs';
     *{$attr . "len"} = sub {
       my $self = shift;
+      if (!defined($self->{$attr})) {
+	return 0 unless @_;
+        $self->{$attr} = '';
+      }
       my $olen = length($self->{$attr});
       return $olen unless @_;
       my $nlen = shift;
--- ./MsgHdr.xs.orig	2003-11-12 07:25:10.000000000 +0000
+++ ./MsgHdr.xs	2006-06-01 10:44:08.000000000 +0000
@@ -38,22 +38,22 @@ hv_2msghdr(struct Socket__MsgHdr *mh, SV
     mh->m.msg_iov    = &mh->io;
     mh->m.msg_iovlen = 1;
 
-    if (svp = hv_fetch(hash, "name", 4, FALSE)) {
+    if ((svp = hv_fetch(hash, "name", 4, FALSE)) && SvOK(*svp)) {
         mh->m.msg_name    = SvPV_force(*svp, dlen);
         mh->m.msg_namelen = dlen;
     }
 
-    if (svp = hv_fetch(hash, "buf", 3, FALSE)) {
+    if ((svp = hv_fetch(hash, "buf", 3, FALSE)) && SvOK(*svp)) {
         mh->io.iov_base = SvPV_force(*svp, dlen);
         mh->io.iov_len  = dlen;
     }
 
-    if (svp = hv_fetch(hash, "control", 7, FALSE)) {
+    if ((svp = hv_fetch(hash, "control", 7, FALSE)) && SvOK(*svp)) {
         mh->m.msg_control    = SvPV_force(*svp, dlen);
         mh->m.msg_controllen = dlen;
     }
 
-    if (svp = hv_fetch(hash, "flags", 5, FALSE)) {
+    if ((svp = hv_fetch(hash, "flags", 5, FALSE)) && SvOK(*svp)) {
         mh->m.msg_flags    = SvIV(*svp);
     }
 }
@@ -109,7 +109,7 @@ smh_unpack_cmsghdr(cmsv)
     for (; cm; cm = CMSG_NXTHDR(&dummy, cm)) {
        XPUSHs(sv_2mortal(newSViv(cm->cmsg_level)));
        XPUSHs(sv_2mortal(newSViv(cm->cmsg_type)));
-       XPUSHs(sv_2mortal(newSVpvn(CMSG_DATA(cm),
+       XPUSHs(sv_2mortal(newSVpvn((char *)CMSG_DATA(cm),
                                  (cm->cmsg_len - aligned_cmsghdr_sz))));
     }
 
@@ -137,7 +137,6 @@ smh_recvmsg(s, msg_hdr, flags = 0)
     PROTOTYPE: $$;$
     PREINIT:
     struct Socket__MsgHdr mh;
-    struct cmsghdr *cm;
         
     CODE:
     hv_2msghdr(&mh, msg_hdr);
@@ -147,11 +146,11 @@ smh_recvmsg(s, msg_hdr, flags = 0)
 
         hsh = (HV*) SvRV(msg_hdr);
 
-        if (svp = hv_fetch(hsh, "name", 7, FALSE))
+        if ((svp = hv_fetch(hsh, "name", 7, FALSE)) && SvOK(*svp))
             SvCUR_set(*svp, mh.m.msg_namelen);
-        if (svp = hv_fetch(hsh, "buf", 3, FALSE))
+        if ((svp = hv_fetch(hsh, "buf", 3, FALSE)) && SvOK(*svp))
             SvCUR_set(*svp, RETVAL);
-        if (svp = hv_fetch(hsh, "control", 7, FALSE))
+        if ((svp = hv_fetch(hsh, "control", 7, FALSE)) && SvOK(*svp))
             SvCUR_set(*svp, mh.m.msg_controllen);
     }
     OUTPUT:
openSUSE Build Service is sponsored by