develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123816] stat should not stack

Thread Previous
From:
Hugo van der Sanden
Date:
February 13, 2015 12:35
Subject:
[perl #123816] stat should not stack
Message ID:
rt-4.0.18-29327-1423830932-1321.123816-75-0@perl.org
# New Ticket Created by  Hugo van der Sanden 
# Please include the string:  [perl #123816]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123816 >


AFL (<http://lcamtuf.coredump.cx/afl>) finds this:

% ./miniperl -e 'stat-t'
miniperl: op.c:721: Perl_op_free: Assertion `!(o->op_private & ~PL_op_private_valid[type])' failed.
Aborted (core dumped)
% 

When trying to stack filetests, ck_ftst() checks that the kid is not a stat or lstat, but doesn't check the parent. I think the fix is just to add the check:

--- a/op.c
+++ b/op.c
@@ -9876,8 +9876,10 @@ Perl_ck_ftst(pTHX_ OP *o)
        }
        if ((PL_hints & HINT_FILETEST_ACCESS) && OP_IS_FILETEST_ACCESS(o->op_type))
            o->op_private |= OPpFT_ACCESS;
-       if (PL_check[kidtype] == Perl_ck_ftst
-               && kidtype != OP_STAT && kidtype != OP_LSTAT) {
+       if (type != OP_STAT && type != OP_LSTAT
+            && PL_check[kidtype] == Perl_ck_ftst
+            && kidtype != OP_STAT && kidtype != OP_LSTAT
+        ) {
            o->op_private |= OPpFT_STACKED;
            kid->op_private |= OPpFT_STACKING;
            if (kidtype == OP_FTTTY && (

.. and will push that with a test if nobody disagrees.

Hugo


Thread Previous


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