Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

This is a short scratch list of easily implementable ideas for defending against readline(*ARGV). The ultimate form would be a module which when loaded subsequently "fixes" everything else. I'm imagining it could be used like perl -MSafeARGV -ne '...'. This "fix" should have no effect any future fixing of this behaviour in the actual codebase.

Idea #0

die("Unsafe readline(*ARGV)") when readline(*ARGV) is detected:

$ perl -MO=Concise -e 'print <>' 7 <@> leave[t1] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 6 <@> print vK ->7 3 <0> pushmark s ->4 5 <1> readline[t1] lK/1 ->6 4 <$> gv(*ARGV) s ->5 *ARGV

Idea #1

Override readline() and pass the filenames to sysopen() instead. Or detect GvNAME for the passed in filehandle and die("Unsafe readline(*ARGV)") if *ARGV is detected.

package SafeReadline; require Exporter; @ISA = 'Exporter'; @EXPORT = 'readline'; sub import { my $pkg = shift; return unless @_; my $sym = shift; $pkg->export("CORE::GLOBAL", $sym, @_); } sub readline { ... }

Idea #2

Alter the optree so that to get the effect of overriding readline() without actually doing that. This would get around the nullifying effects of multiple readline() overriding modules. Ok, this is harder, would require some tuits, and leaves anything less than 5.8.0 out in the cold (B::Generate is only for 5.8.0 and above).

In reply to Re: Dangerous diamonds! by diotalevi
in thread Dangerous diamonds! by Juerd

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (5)
    As of 2020-01-25 06:11 GMT
    Find Nodes?
      Voting Booth?