Yous most holy monk types...

I'm working on something that uses tainting and Expect. Expect's logfile feature uses IO::File to open the logfile. If you open the Expect log file with a relative path, IO::File uses File::Spec->rel2abs to convert it to an absolute file name.

My quibble is, if I use a relative path, and I've un-tainted that file name, IO::File will taint it when it converts it to an absolute path. The script dies complaining about the tainted value, but the error doesn't say anything about how it's the conversion from relative to absolute that's causing the tainting.

I consider this a bug in IO::File, and I'd like to make a patch.

Here are my actual questions:

Do you agree that this is a bug?

What's the best way to handle this?

Make it not taint the value somehow? I'd have to untaint the new absolute path. That might not actually be bad, if I check to make sure the relative path is not tainted then the absolute path should be OK by definition, right? Hmmm.. maybe not... I could make a dir with a name like "rm -r /", cd to it and then invoke this thing... Yeah, that would be bad...

Make it die with a more informative error? If I can check to see if taint checking is on, then I could see if the value goes from un-tainted to tainted and issue a warning. That's probably the best choice.

What do you all think?

Thanks!

-Pileofrogs


In reply to IO::File tainting quibble by pileofrogs

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.