iliaa Wed Mar 2 22:30:24 2005 EDT
Modified files: (Branch: PHP_5_0)
/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.1760.2.269&r2=1.1760.2.270&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1760.2.269 php-src/NEWS:1.1760.2.270
--- php-src/NEWS:1.1760.2.269 Wed Mar 2 13:14:34 2005
+++ php-src/NEWS Wed Mar 2 22:30:22 2005
@@ -29,6 +29,8 @@
is passed. (Tony)
- Fixed posix_getsid() & posix_getpgid() to return sid & pgid instead
of true. (Tony)
+- Fixed bug #32160 (file truncation in copy() when source & destination are
+ the same). (Ilia)
- Fixed bug #32130 (ArrayIterator::seek() does not throw an Exception on
invalid index). (Marcus)
- Fixed bug #32081 (in mysqli default socket value is not being used). (Ilia)
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.382.2.3&r2=1.382.2.4&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.382.2.3
php-src/ext/standard/file.c:1.382.2.4
--- php-src/ext/standard/file.c:1.382.2.3 Mon Dec 6 18:31:07 2004
+++ php-src/ext/standard/file.c Wed Mar 2 22:30:23 2005
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.382.2.3 2004/12/06 23:31:07 iliaa Exp $ */
+/* $Id: file.c,v 1.382.2.4 2005/03/03 03:30:23 iliaa Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -1625,6 +1625,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, NULL);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php