Change 34261 by [EMAIL PROTECTED] on 2008/09/04 06:02:02

        Integrate:
        [ 34055]
        Subject: [perl #55786] [PATCH blead] Re: Overload Segfaulting 
        From: Rick Delaney (via RT) <[EMAIL PROTECTED]>
        Date: Sat, 14 Jun 2008 11:51:01 -0700
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 34067]
        Subject: [perl #46309] Buffer overflow in win32_select() (PATCH 
included) 
        From: Risto Kankkunen (via RT) <[EMAIL PROTECTED]>
        Date: Wed, 10 Oct 2007 02:44:13 -0700
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/maint-5.10/perl/lib/overload.pm#2 integrate
... //depot/maint-5.10/perl/lib/overload.t#2 integrate
... //depot/maint-5.10/perl/pp.h#3 integrate
... //depot/maint-5.10/perl/win32/win32sck.c#2 integrate

Differences ...

==== //depot/maint-5.10/perl/lib/overload.pm#2 (text) ====
Index: perl/lib/overload.pm
--- perl/lib/overload.pm#1~32694~       2007-12-22 01:23:09.000000000 -0800
+++ perl/lib/overload.pm        2008-09-03 23:02:02.000000000 -0700
@@ -588,7 +588,8 @@
 
 If the copy constructor is required during the execution of some mutator,
 but a method for C<'='> was not specified, it can be autogenerated as a
-string copy if the object is a plain scalar.
+string copy if the object is a plain scalar or a simple assignment if it
+is not.
 
 =over 5
 
@@ -675,7 +676,8 @@
 =item I<Copy operator>
 
 can be expressed in terms of an assignment to the dereferenced value, if this
-value is a scalar and not a reference.
+value is a scalar and not a reference, or simply a reference assignment
+otherwise.
 
 =back
 

==== //depot/maint-5.10/perl/lib/overload.t#2 (text) ====
Index: perl/lib/overload.t
--- perl/lib/overload.t#1~32694~        2007-12-22 01:23:09.000000000 -0800
+++ perl/lib/overload.t 2008-09-03 23:02:02.000000000 -0700
@@ -47,7 +47,7 @@
 package main;
 
 $| = 1;
-use Test::More tests => 556;
+use Test::More tests => 558;
 
 
 $a = new Oscalar "087";
@@ -1427,4 +1427,20 @@
     is($aref**1, $num_val, 'exponentiation of ref');
 }
 
+{
+    package CopyConstructorFallback;
+    use overload
+        '++'        => sub { "$_[0]"; $_[0] },
+        fallback    => 1;
+    sub new { bless {} => shift }
+
+    package main;
+
+    my $o = CopyConstructorFallback->new;
+    my $x = $o++; # would segfault
+    my $y = ++$o;
+    is($x, $o, "copy constructor falls back to assignment (postinc)");
+    is($y, $o, "copy constructor falls back to assignment (preinc)");
+}
+
 # EOF

==== //depot/maint-5.10/perl/pp.h#3 (text) ====
Index: perl/pp.h
--- perl/pp.h#2~33139~  2008-01-30 15:19:42.000000000 -0800
+++ perl/pp.h   2008-09-03 23:02:02.000000000 -0700
@@ -487,9 +487,9 @@
 
 /* SV* ref causes confusion with the member variable
    changed SV* ref to SV* tmpRef */
-#define RvDEEPCP(rv) STMT_START { SV* tmpRef=SvRV(rv);      \
-  if (SvREFCNT(tmpRef)>1) {                 \
-    SvRV_set(rv, AMG_CALLun(rv,copy)); \
+#define RvDEEPCP(rv) STMT_START { SV* tmpRef=SvRV(rv); SV* rv_copy;     \
+  if (SvREFCNT(tmpRef)>1 && (rv_copy = AMG_CALLun(rv,copy))) {          \
+    SvRV_set(rv, rv_copy);                 \
     SvREFCNT_dec(tmpRef);                   \
   } } STMT_END
 

==== //depot/maint-5.10/perl/win32/win32sck.c#2 (text) ====
Index: perl/win32/win32sck.c
--- perl/win32/win32sck.c#1~32694~      2007-12-22 01:23:09.000000000 -0800
+++ perl/win32/win32sck.c       2008-09-03 23:02:02.000000000 -0700
@@ -259,9 +259,8 @@
 {
     int r;
 #ifdef USE_SOCKETS_AS_HANDLES
-    Perl_fd_set dummy;
     int i, fd, save_errno = errno;
-    FD_SET nrd, nwr, nex, *prd, *pwr, *pex;
+    FD_SET nrd, nwr, nex;
 
     /* winsock seems incapable of dealing with all three null fd_sets,
      * so do the (millisecond) sleep as a special case
@@ -275,44 +274,31 @@
        return 0;
     }
     StartSockets();
-    PERL_FD_ZERO(&dummy);
-    if (!rd)
-       rd = &dummy, prd = NULL;
-    else
-       prd = &nrd;
-    if (!wr)
-       wr = &dummy, pwr = NULL;
-    else
-       pwr = &nwr;
-    if (!ex)
-       ex = &dummy, pex = NULL;
-    else
-       pex = &nex;
 
     FD_ZERO(&nrd);
     FD_ZERO(&nwr);
     FD_ZERO(&nex);
     for (i = 0; i < nfds; i++) {
        fd = TO_SOCKET(i);
-       if (PERL_FD_ISSET(i,rd))
+       if (rd && PERL_FD_ISSET(i,rd))
            FD_SET((unsigned)fd, &nrd);
-       if (PERL_FD_ISSET(i,wr))
+       if (wr && PERL_FD_ISSET(i,wr))
            FD_SET((unsigned)fd, &nwr);
-       if (PERL_FD_ISSET(i,ex))
+       if (ex && PERL_FD_ISSET(i,ex))
            FD_SET((unsigned)fd, &nex);
     }
 
     errno = save_errno;
-    SOCKET_TEST_ERROR(r = select(nfds, prd, pwr, pex, timeout));
+    SOCKET_TEST_ERROR(r = select(nfds, &nrd, &nwr, &nex, timeout));
     save_errno = errno;
 
     for (i = 0; i < nfds; i++) {
        fd = TO_SOCKET(i);
-       if (PERL_FD_ISSET(i,rd) && !FD_ISSET(fd, &nrd))
+       if (rd && PERL_FD_ISSET(i,rd) && !FD_ISSET(fd, &nrd))
            PERL_FD_CLR(i,rd);
-       if (PERL_FD_ISSET(i,wr) && !FD_ISSET(fd, &nwr))
+       if (wr && PERL_FD_ISSET(i,wr) && !FD_ISSET(fd, &nwr))
            PERL_FD_CLR(i,wr);
-       if (PERL_FD_ISSET(i,ex) && !FD_ISSET(fd, &nex))
+       if (ex && PERL_FD_ISSET(i,ex) && !FD_ISSET(fd, &nex))
            PERL_FD_CLR(i,ex);
     }
     errno = save_errno;
End of Patch.

Reply via email to