iliaa Wed Mar 2 22:32:00 2005 EDT Modified files: (Branch: PHP_4_3) /php-src NEWS /php-src/ext/standard file.c Log: MFH: Fixed bug #32160 (file truncation in copy() when source & destination are the same). http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1247.2.848&r2=1.1247.2.849&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1247.2.848 php-src/NEWS:1.1247.2.849 --- php-src/NEWS:1.1247.2.848 Tue Mar 1 16:34:29 2005 +++ php-src/NEWS Wed Mar 2 22:31:57 2005 @@ -17,6 +17,8 @@ - Fixed several leaks in ext/filepro. (Tony) - Fixed build system to always use bundled libtool files. (Jani) - Fixed MacOSX shared extensions crashing on Apache startup. (Rasmus) +- Fixed bug #32160 (file truncation in copy() when source & destination are + the same). (Ilia) - Fixed bug #31960 (msql_fetch_row() and msql_fetch_array() dropping columns with NULL values). (Daniel Convissor) - Fixed bug #31936 (set_h_errno() is redefined incompatibly). (Jani) http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.68&r2=1.279.2.69&ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.279.2.68 php-src/ext/standard/file.c:1.279.2.69 --- php-src/ext/standard/file.c:1.279.2.68 Mon Jan 17 19:14:56 2005 +++ php-src/ext/standard/file.c Wed Mar 2 22:31:59 2005 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.279.2.68 2005/01/18 00:14:56 iliaa Exp $ */ +/* $Id: file.c,v 1.279.2.69 2005/03/03 03:31:59 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2141,6 +2141,12 @@ { php_stream *srcstream = NULL, *deststream = NULL; int ret = FAILURE; + struct stat src_s, dest_s; + + /* safety check to ensure that source & destination files are not the same file */ + if (stat(src, &src_s) || (stat(dest, &dest_s) == 0 && src_s.st_ino == dest_s.st_ino)) { + return ret; + } srcstream = php_stream_open_wrapper(src, "rb", STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS,
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php