<?xml version="1.0" encoding="windows-1252"?>
<node id="783905" title="Inline.pm and untainting" created="2009-07-28 07:55:19" updated="2009-07-28 07:55:19">
<type id="115">
perlquestion</type>
<author id="524150">
syphilis</author>
<data>
<field name="doctext">
Hi,&lt;br&gt;
In Inline.pm we have the following subroutine which gets called whenever the Config option 'UNTAINT' is set:
&lt;c&gt;
#==============================================================================
# Blindly untaint tainted fields in Inline object.
#==============================================================================
sub env_untaint {
    my $o = shift;

    for (keys %ENV) {
	($ENV{$_}) = $ENV{$_} =~ /(.*)/;
    }
    my $delim = $^O eq 'MSWin32' ? ';' : ':';
    $ENV{PATH} = join $delim, grep {not /^\./ and -d $_ and
				      not ((stat($_))[2] &amp; 0022)
				  } split $delim, $ENV{PATH};
    map {($_) = /(.*)/} @INC;
}
&lt;/c&gt;
And that works quite well on linux, untainting $ENV{PATH} and leaving it intact. But on windows it clobbers $ENV{PATH}, leaving it empty.&lt;br&gt;&lt;br&gt;The culprit is the &lt;c&gt;not ((stat($_))[2] &amp; 0022)&lt;/c&gt; condition. On linux, where &lt;c&gt;stat($_))[2]&lt;/c&gt; is 16877 for all of the folders in my path, &lt;c&gt;((stat($_))[2] &amp; 0022)&lt;/c&gt; is false. But on windows &lt;c&gt;stat($_))[2]&lt;/c&gt; is 16895 for all of the folders in my path, and &lt;c&gt;((stat($_))[2] &amp; 0022)&lt;/c&gt; is true.&lt;br&gt;&lt;br&gt;If I simply remove that condition for windows, everything is fine. But is that the correct thing to do ? Why has that condition been put in there, and what's the correct windows form it should take ? &lt;br&gt;&lt;br&gt;Cheers,&lt;br&gt;Rob</field>
</data>
</node>
