Re: cvs: php-src /ext/standard file.c
| From: | Andi Gutmans | Date: | Fri, 11 Mar 2005 17:01:53 +0000 |
| Subject: | Re: cvs: php-src /ext/standard file.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-30875@lists.php.net to get a copy of this message | ||
Shouldn't you also be comparing device? Inode is not necessarily unique.
At 03:29 AM 3/3/2005 +0000, Ilia Alshanetsky wrote:
iliaa Wed Mar 2 22:29:24 2005 EDTModified files:/php-src/ext/standard file.cLog: Fixed bug #32160 (file truncation in copy() when source & destination are the same). http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.398&r2=1.399&ty=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.398 php-src/ext/standard/file.c:1.399 --- php-src/ext/standard/file.c:1.398 Thu Feb 17 08:56:49 2005 +++ php-src/ext/standard/file.c Wed Mar 2 22:29:23 2005 @@ -21,7 +21,7 @@+----------------------------------------------------------------------+*/ -/* $Id: file.c,v 1.398 2005/02/17 13:56:49 hyanantha Exp $ */ +/* $Id: file.c,v 1.399 2005/03/03 03:29:23 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1699,6 +1699,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