Wierdly, it seems that in perl 5.8.8, either of packing and unpacking with "B*" untaints, unpacking with "N*" untaints; but packing with "N*" or packing and unpacking with "C*" or "a*" doesn't untaint a scalar. I've no idea what the correct behaiviour should be.

Not really related, but note that this command doesn't raise an insecure dependency error:

perl -wTe '() = unpack $ARGV[0], 1e9;' p
it segfaults.

However, the result of such an unpack is tainted, as can be seen from the error from this command.

perl -wTe '$z = pack "p", "hi\n"; $r = unpack $ARGV[0], $z; eval $r;' +p

Update: I forgot to say that I found this bug when re-examining Re: What's your favourite method of untainting?.

Update: see perlbug ticket #52552.


In reply to Re: pack() untaints data : bug or undocumented Perl 5.10 feature? by ambrus
in thread pack() untaints data : bug or undocumented Perl 5.10 feature? by mr_mischief

Title:
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, details, 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, summary, 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.