develooper Front page | perl.perl5.porters | Postings from March 2012

[perl #111500] Bleadperl v5.15.7-88-g7e4f045 breaks MLEHMANN/common-sense-3.4.tar.gz

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
March 6, 2012 13:29
Subject:
[perl #111500] Bleadperl v5.15.7-88-g7e4f045 breaks MLEHMANN/common-sense-3.4.tar.gz
Message ID:
rt-3.6.HEAD-4610-1331069338-1202.111500-15-0@perl.org
On Tue Mar 06 13:20:44 2012, zefram@fysh.org wrote:
> Father Chrysostomos via RT wrote:
> >Does anyone see anything wrong with applying that now?
> 
> Yes, it looks like you've completely misunderstood

No, I just wrote the patch too quickly. :-)

> how the size
> is managed.  Your change would copy a fixed number of bytes into the
> warning structure, ignoring the actual size of the input.
> 
> As I noted earlier in this thread, the core's internal warning bit
> checks don't check that there are enough bits in the warning vector.
> But that's fine as long as it's only checking the statically-allocated
> warning categories and the user never writes an abnormally short bitset
> into ${^WARNING_BITS}.  This does provide yet another, particularly
> easy, way to make perl break memory discipline, but it's through quite
> an explicit port into the internals.  It won't arise if the user only
> writes bitsets previously read from the same place.

What Marc Lehmann says about an old common::sense being used with a
newer perl is a valid concern.

Here is a better version:

diff --git a/util.c b/util.c
index 1ff5913..a147ae0 100644
--- a/util.c
+++ b/util.c
@@ -2002,7 +2002,7 @@ S_ckwarn_common(pTHX_ U32 w)
 STRLEN *
 Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer, const char *const bits,
 			   STRLEN size) {
-    const MEM_SIZE len_wanted = sizeof(STRLEN) + size;
+    const MEM_SIZE len_wanted = sizeof(STRLEN) + WARNsize;
     PERL_UNUSED_CONTEXT;
     PERL_ARGS_ASSERT_NEW_WARNINGS_BITFIELD;
 
@@ -2012,6 +2012,8 @@ Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer,
const char *const bits,
 	 PerlMemShared_realloc(buffer, len_wanted));
     buffer[0] = size;
     Copy(bits, (buffer + 1), size, char);
+    if (size < WARNsize)
+	Zero(bits, (char *)(buffer + 1) + size, WARNsize - size, char);
     return buffer;
 }
 


-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=111500

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About