php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #590 File Upload Seg Fault
Submitted: 1998-07-28 13:18 UTC Modified: 1998-09-12 18:44 UTC
From: jwalsh at verio dot net Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 3.0.2a OS: Solaris 2.5x
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jwalsh at verio dot net
New email:
PHP Version: OS:

 

 [1998-07-28 13:18 UTC] jwalsh at verio dot net
Configuration: See http://sac.verio.net/info.php3

Problem: As soon as the "Import Passwords" button is clicked, I get a "Document Contains no Data" and the following error in the error_log.

     [Tue Jul 28 10:02:02 1998] [notice] httpd: child pid 10902 exit signal Segmentation Fault (11)

This worked fine with PHP 3.0, but not with 3.0.1 either.

Code Chunk:

<?
function MyErr() {
	print ("
<html>
<head><title>CCAPTA: Error!</title></head>
<body bgcolor=\"#9eb8df\">
<p align=\"center\"><img src=\"http://www.ccapta.org/CCAPTALogo.GIF\"
WIDTH=\"551\" HEIGHT=\"103\"></p>
<table border=\"0\" width=\"550\" cellspacing=\"0\" align=\"center\"> 
  <tr>
    <td bgcolor=\"#808080\" align=\"center\"><font
    size=\"4\"><strong>Error!</strong></font></td>
  </tr>
  <tr>
    <td>File not uploaded correctly</td>
  </tr>
</table>
</body>
</html>
  	");
  	exit;
}

if( $mode == "update" ) {
	if( $file == "none" ) {
    	MyErr();
	} else {
    	echo "<p align=\"center\">Conversion In Progress . . .<BR>\n";
    	/* echo "Original file name: $upfile_name<BR>\n"; 
    	echo "File in upload_tmp_dir: $upfile<BR>\n"; 
    	echo "File size: $upfile_size<BR>\n"; 
    	echo "File type: $upfile_type<BR>\n"; */
		echo "This operation may take up to 2 minutes.<BR>\n";

		$htpasswd = "/home/virtual/Rabbits/members/.htpasswd";
		exec( "cp $upfile /home/virtual/Rabbits/admin/." );
		$fp = fopen( $upfile, "r+" );
		$original = fread( $fp, filesize( $upfile ) );
		$new = ereg_replace( "\r", "\n", $original );
		fwrite( $fp, $new, filesize( $upfile ) );
		fclose( $fp );
		$rawfile = @file( $upfile );
		$fp = fopen( $htpasswd, "w" );

		for( $i = 0; $i <= count( $rawfile ); $i++ ) {
			$rawline = $rawfile[$i];
			$rawline = explode( ",", ereg_replace( "\"", "", $rawline ) );
			$newline = $rawline[0].":".crypt( $rawline[1], substr( $rawline[1], 1, 2 ) )."\n";
			fputs( $fp, $newline);
		}

		fclose( $fp );
		exec( "rm $upfile" );
	}
	
	echo "Password file conversion complete.</p>\n";
} else {
	echo "Normal<BR>\n";
}
?>
<html>
<head>
<title>CCAPTA Password Admin</title>
</head>

<body bgcolor="#9eb8df">

<p align="center"><img src="http://www.ccapta.org/CCAPTALogo.GIF" WIDTH="551"
HEIGHT="103"></p>
<div align="center"><center>

<table border="0" width="550" cellspacing="0">
  <tr>
    <td bgcolor="#808080" align="center"><font size="4"><strong>Web Password
    Administration</strong></font></td>
  </tr>
  <tr>
    <td>Please click on &quot;Browse&quot; button to
    select which file you would like to upload and click the
    &quot;Import Passwords&quot; button to update the protected site
    access list. The file used to update the password list must be
    saved as a comma delimited, quote encapsulated ASCII file.&nbsp;
    The file name you use to update the list can be whatever you want
    it to be <b>but the file name cannot include special characters
    such as &amp;, $, !, #, @, %, *, or ^.</b>
    <form enctype="multipart/form-data" action="<? echo $PHP_SELF ?>" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="200000">
	<input type="hidden" name="mode" value="update">
    <p>File to Upload: <input type="file" name="upfile" size="40"
    maxlength="255"></p>
    <div align="center"><input type="submit" value="Import Passwords"></div>
    </form>
    </td>
  </tr>
  <tr>
    <td align="center"><font size="2"><br>
    Please report any problems with this web application to <a
    href="mailto:webmaster@sac.verio.net">webmaster@sac.verio.net</a>.</font></td>
  </tr>
</table>
</center></div>
</body>
</html>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-09-12 18:44 UTC] zeev
Any chance you could run your server under gdb and get us a backtrace of this seg fault?

--

This doesn't look like a file upload problem to me, it
probably crashes in the code that processes the uploaded
file and not during the file upload itself.

My guess is that you've compiled/linked the regex
libraries badly.  See the FAQ for additional
details.

To check if this is indeed the case, comment out
the regular expression calls (all ereg*() functions) and
see if it still crashes.  If it doesn't, it means that
you have a regex messup that you need to fix.
If it still does, please try to remove get the smallest
script snippet that still reproduces the problem, and
submit a new bug report.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 04:01:38 2025 UTC