in reply to UTF8 related proof of concept exploit released at T-DOSE
And in doing so, it would usually be prudent to do it like this (adapting the sample code given in the OP):
#!/usr/bin/perl -T use strict; use Encode; %ENV = ( PATH => '/usr/bin' ); open my $filehandle, "< :raw", "test.bin" or die $!; my $word = readline $filehandle; eval { $word = decode( "utf8", $word, Encode::FB_CROAK ) }; if ( $@ ) { warn "unusable input from test.bin\n"; } else { my ($untainted) = $word =~ /^(\w+)$/; if ($untainted) { # It passed the regex, so it is "safe". system "echo $untainted"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UTF8 related proof of concept exploit released at T-DOSE
by Juerd (Abbot) on Oct 14, 2007 at 23:06 UTC | |
by graff (Chancellor) on Oct 15, 2007 at 08:57 UTC | |
by Juerd (Abbot) on Oct 15, 2007 at 16:09 UTC |