in reply to Safely passing CGI form data to a shell command
exec @list doesn't use the shell to parse and run the command so you don't need to bother about a malicious user passing things like "hello; rm -rf /"...# untested my @out; my $pid=open my $pipe, '-|'; defined $pid or croak "fork failed"; if ($pid==0) { exec $command, $opt1, $opt2, ..., '--', $arg1, $arg2, ... exit(0); } else { @out=<$pipe> }
well, you have to be sure that the called program doesn't pass its arguments to a shell either!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Safely passing CGI form data to a shell command
by Tommy (Chaplain) on Apr 21, 2005 at 17:00 UTC | |
by salva (Canon) on Apr 21, 2005 at 17:18 UTC |