Gossamer Forum
Home : General : Perl Programming :

Newbie to Perl - having issue opening file for append

Quote Reply
Newbie to Perl - having issue opening file for append
I just want to write out form input to a text file. So, after I've got the form input parsed I have this line:

open (FH, ">>$tfile");

Which generates this error:

Insecure dependency in open while running setgid at postcomments.pl line 19.

Thanks for any and all thoughts.

Here's more of the script:

#!/usr/local/bin/perl

require TripodCGI;

$CGI= new TripodCGI;
$tfile=$CGI->param('comment_text');
$hfile=$CGI->param('comment_html');
$name=$CGI->param('uname');
$email=$CGI->param('email');
$rating=$CGI->param('rating');
$comments=$CGI->param('comment_area');

open (FH, ">>$tfile");
flock(FH,2);
seek(FH,0,2);
print FH qq!
<tr><td><img src="invisible.gif" width="15" height="1"></td>
<td align="right"><img src="ktcl1l.gif" width="73" height="47" border="0"></td>
<td>$name<br>$email<br>$rating<br>$comments<br><center><img src="ktln1f.gif" width="474" height="89" border="0"><br></td></tr>!;
close(FH);
$CGI->redirect('$hfile');
exit;

Last edited by:

beandandpeanut: Oct 6, 2003, 12:55 PM
Quote Reply
Re: [beandandpeanut] Newbie to Perl - having issue opening file for append In reply to
Directly using form input in some functions is very unsafe. For example, the open() function can also be used to execute system commands. Instead of including the name of the file you'll be writing to as part of form input, you should have that as an internal variable. You should also do some return value error checking on your open/flock/close functions.

Philip
------------------
Limecat is not pleased.