From: farayi dot nyamadzawo at unodc dot org Operating system: Redhat PHP version: 5.2.2 PHP Bug Type: Filesystem function related Bug description: Segmentation core dump glibc detected *** free(): invalid next size
Description: ------------ I am running the below script from command line.it gives me a segmentation error when it is trying to download files and save them and return any arraz. I get the following error glibc detected *** free(): invalid next size function attached below ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-openssl --with-zlib --enable-bcmath --enable-calendar --with-curl --enable-dom --enable-exif --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr --with-iconv --enable-json --with-mysql --enable-xml --with-xsl --enable-zip --enable-shared --with-ldap=/usr --with-mysqli --enable-mbstring PHP 5.2.2 (cli) Archive_Tar 1.3.2 stable Console_Getopt 1.2.2 stable DB 1.7.11 stable PEAR 1.5.4 stable Structures_Graph 1.0.2 stable Reproduce code: --------------- function upload_file_from_url($filename, $url, $dir = 'transfer/docs/', $overwrite_uid = false) { //ver. 2.0 //error_reporting(E_ALL); if($fp = fopen($url,"rb")) //file exists { logmsg ("DEBUG:UPLOAD - open remote file."); //generate UNQ name $filename = $filename; $filetype = 'application/octet-stream'; $fileinfo = pathinfo($filename); $fname = $fileinfo['filename']; $filedata = ''; logmsg ("DEBUG:UPLOAD - read remote file."); while (!feof($fp)) { $filedata .= fread($fp, 8192); } if(!$filedata) { fclose($fp); return false; } logmsg ("DEBUG:UPLOAD - reading done!"); logmsg ("DEBUG:UPLOAD - check file size"); $filesize = strlen($filedata); if($filesize == 0) { fclose($fp); return false; } logmsg ("DEBUG:UPLOAD - size is ok:{$filesize}"); logmsg ("DEBUG:UPLOAD - check existance of filename"); //check file exists $exists = true; $i = 0; while(file_exists($this->web_root.$dir.$fname.'.'.$fileinfo['extension'])) { $i++; $fname.= '-'.$i; } $filepath = $fname.'.'.$fileinfo['extension']; logmsg ("DEBUG:UPLOAD - check name done. using - ".$filepath); logmsg ("DEBUG:UPLOAD - copy data.."); //store file $fpl = fopen($this->web_root.$dir.$filepath,"w"); if($fpl) { fwrite($fpl,$filedata,$filesize); fclose($fpl); } else { fclose($fp); return false; } fclose($fp); logmsg ("DEBUG:UPLOAD - data copied - done."); return array('name' => $filename,'size'=>$filesize, 'path'=> $filepath); } else { return false; } } Expected result: ---------------- download files from website , store and return array -- Edit bug report at http://bugs.php.net/?id=41451&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41451&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41451&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41451&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41451&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41451&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41451&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41451&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41451&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41451&r=support Expected behavior: http://bugs.php.net/fix.php?id=41451&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41451&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41451&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41451&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41451&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41451&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41451&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41451&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41451&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41451&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41451&r=mysqlcfg