This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
S_do_op_dump_bar(): don't print TRANS op_pv field
authorDavid Mitchell <davem@iabyn.com>
Mon, 27 Feb 2017 13:15:31 +0000 (13:15 +0000)
committerDavid Mitchell <davem@iabyn.com>
Mon, 27 Feb 2017 13:15:31 +0000 (13:15 +0000)
My recent commit v5.25.9-32-gabd07ec made dump.c display the op_pv
string of OP_NEXT, OP_TRANS etc ops. However, for OP_TRANS/OP_TRANSR,
the string is basically a 256-byte potentially non null-temrinated array.
This was causing a buffer read overrun and garbage to be displayed.

The simple solution is to only display the address but not contents
for a trans op. OP_NEXT ec labels continue to be displayed.

dump.c

diff --git a/dump.c b/dump.c
index 52b52ca..c5e3a79 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -1227,21 +1227,22 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
     case OP_REDO:
        if (o->op_flags & (OPf_SPECIAL|OPf_STACKED|OPf_KIDS))
            break;
-       /* FALLTHROUGH */
-    case OP_TRANS:
-    case OP_TRANSR:
-       if (   (o->op_type == OP_TRANS || o->op_type == OP_TRANSR)
-            && (o->op_private & (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF)))
-            break;
-
         {
             SV * const label = newSVpvs_flags("", SVs_TEMP);
             generic_pv_escape(label, cPVOPo->op_pv, strlen(cPVOPo->op_pv), 0);
             S_opdump_indent(aTHX_ o, level, bar, file,
                             "PV = \"%" SVf "\" (0x%" UVxf ")\n",
                             SVfARG(label), PTR2UV(cPVOPo->op_pv));
+            break;
         }
 
+    case OP_TRANS:
+    case OP_TRANSR:
+            S_opdump_indent(aTHX_ o, level, bar, file,
+                            "PV = 0x%" UVxf "\n",
+                            PTR2UV(cPVOPo->op_pv));
+            break;
+
 
     default:
        break;