Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 2845 - Perl cgi-bin bug
Summary: Perl cgi-bin bug
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: perl
Version: 5.2
Hardware: i386
OS: Linux
high
high
Target Milestone: ---
Assignee: Crutcher Dunnavant
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-05-15 21:15 UTC by aftab
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 1999-08-30 02:33:54 UTC


Attachments (Terms of Use)

Description aftab 1999-05-15 21:15:04 UTC
I have recently installed Redhat Linux, and when I copied
my web page from my PC to linux, it did not execute the
scripts properly. I have also updated my perl version with
the latest update on you web site (14/05/99)and still had
the same problem. After some debugging I have found what
the problem is: I pass a reference to an associate array to
a subroutine. This subroutine then fills in this array. But
the items this subroutine enters into the array are not
visable outside this array as they should be as I passed
the array by reference. These scripts have been working on
my PC and on ISP unix machine. The contenets of the script
are below.

#!/usr/bin/perl

&parse_input(*login_form);

#the login_form is empty it does not get filled as it should

$userid = $login_form{'userid'};
$pass = $login_form{'pass'};

#the subroutine
sub parse_input {
	if (defined(@_)) {
		local(*input)=@_;
	}
	else {
		local(*input)="*cgiinput";
	}
	local ($temp,@pairs);
	if (&form_method eq 'POST') {
		read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
	}
	else {
		$temp=$ENV{'QUERY_STRING'};
	}
	if ($temp ne '') {
		@pairs=split(/&/,$temp);
		foreach $item(@pairs) {
			($key,$content)=split (/=/,$item,2);
			$content=~tr/+/ /;
			$content=~ s/%(..)/pack("c",hex
($1))/ge;
			if (!defined($input{$key})) {
				$input{$key}=$content;
			}
			else {
				$input{$key} .= "\0
$content";
			}
		}
		return 1;
	}
	else {
		return 0;
	}
}

Comment 1 Cristian Gafton 1999-08-30 02:33:59 UTC
You can change the perl fucntion to return the actual array instead
of 	playing the by-refreence game, whcih is totally evil. At a first
fast glance I got scaried by things like
	$input{$key} .= "\0$content";
I'd suggest you rather use the CGI module if you want to parse this
kind of free form variables.


Note You need to log in before you can comment on or make changes to this bug.