Return-Path: Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 8342 invoked by uid 500); 14 May 2002 09:51:48 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 8330 invoked from network); 14 May 2002 09:51:48 -0000 Date: Tue, 14 May 2002 11:51:57 +0200 Subject: Problem with tied STDIN, CGI.pm mod_perl 1.26 and perl 5.6.1 Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v481) Cc: dev@perl.apache.org To: lstein@cshl.org From: Arthur Bergman Content-Transfer-Encoding: 7bit Message-Id: <3ACA9638-6720-11D6-96B3-003065D64CBE@contiller.se> X-Mailer: Apple Mail (2.481) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, After tons of debugging a case when I lost CGI POST variables I discovered the following. In perl 5.6.1, certain operations can cause references to filehandles to loose TIE magic even when the filehandle is tied. Witness. use strict; use IO::Scalar; sub IO::Scalar::FILENO {}; my $scalar = ""; tie *STDIN, 'IO::Scalar', \$scalar; fileno(STDIN); my $fh = \*STDIN; print $fh "HI"; print "---$scalar---\n"; Removing the fileno(STDIN), makes the above example work. This is fixed in perl 5.8 to be, I don't know how far back it has effect I only tried it under 5.6.1. The result is that if a module does fileno(STDIN), or any of the other potential ops (Anyone doing sv_setsv on a glob), any references to STDIN will not be tied, however since CGI.pm reads STDIN for post data from a reference to STDIN, and mod_perl makes it tied, suddenly post data will not appear. Worst case it will hang since it does a read( from /dev/null which is what plain STDIN is under apache on linux). The following patch corrects the problem without having any bad side effects as far as I know. --- CGI.pm~ Wed Apr 10 21:36:01 2002 +++ CGI.pm Tue May 14 11:34:22 2002 @@ -450,7 +450,7 @@ } if ($meth eq 'POST') { - $self->read_from_client(\*STDIN,\$query_string,$content_length,0) + $self->read_from_client('STDIN',\$query_string,$content_length,0) if $content_length > 0; # Some people want to have their cake and eat it too! # Uncomment this line to have the contents of the query string Arthur --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org For additional commands, e-mail: dev-help@perl.apache.org