in reply to eval() and security
my $x = <STDIN>; eval($x); <-- eval EXPR
Despite the similarity in names, those are very different functions. You're really comparingmy $x = <STDIN>; eval{ (my $s = "blah blah") =~ /$x/ } <-- eval BLOCK
witheval($x)
'' =~ /$x/
The regex engine has checks in place to prevents the execution of Perl code in interpolated variables, so it's pretty safe. (use re 'eval'; removes the checks. no re 'eval'; adds them.)
However, there is another class of problems you have to worry about. $x could contain a pattern that takes longer the life of the Universe to execute. This could be used to mount a denial of service attack.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: eval() and security
by halfcountplus (Hermit) on Nov 24, 2009 at 19:21 UTC |