You can simplify things massively by using the CGI.pm module which is supplied as part of the standard Perl distribution. To get, for example, the value of a form field 'email', you'd use:
# these first 2 lines should be used once,
# near the top of your script
use CGI;
$query=CGI::new();# then actually retrieve the value
$email=$query->param("email");
print "$email\n";
exit;
CGI.pm is capable of much, much more than this (eg cookies), but this is a great simplifier to get started with.
my ($buffer, @pairs, $name, $value);
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\r//g;
$FORM{$name} = $value;
print "<br>Form name : <b>$name</b> Value : <b> $value </b>\n" if ($debug >4);
}
Are there any sites out there giving details of specific security concerns?
I think the problem with the above has to do with length and a buffer overrun.
Examples here [eekim.com]