php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52802 Out-of-date comment for file_get_contents/php_stream_copy_to_mem
Submitted: 2010-09-09 13:36 UTC Modified: 2010-09-10 05:08 UTC
From: cataphract@php.net Assigned: aharvey (profile)
Status: Closed Package: Streams related
PHP Version: trunk-SVN-2010-09-09 (SVN) OS:
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: cataphract@php.net
New email:
PHP Version: OS:

 

 [2010-09-09 13:36 UTC] cataphract@php.net
Description:
------------
ext/standard/file.c#560

    560 	/* uses mmap if possible */
    561 	if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {

main/php_streams.h

    431 /* read all data from stream and put into a buffer. Caller must free buffer when done.
    432  * The copy will use mmap if available. */
    433 PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen,
    434 		int persistent STREAMS_DC TSRMLS_DC);
    435 #define php_stream_copy_to_mem(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_CC TSRMLS_CC)

main/php_streams.h

    419 /* copy up to maxlen bytes from src to dest.  If maxlen is PHP_STREAM_COPY_ALL, copy until eof(src).
    420  * Uses mmap if the src is a plain file and at offset 0 */
    421 #define PHP_STREAM_COPY_ALL		((size_t)-1)

In this last case, PHP_STREAM_COPY_ALL is also passed to php_stream_copy_to_stream_ex, which still uses mmap+mmap_unmap, so it's half correct (except for the part is works with any maxlen, not just PHP_STREAM_COPY_ALL).


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-09 13:38 UTC] cataphract@php.net
Forgot the tell. The behavior of php_stream_copy_to_mem was modified in March 2008:

http://svn.php.net/viewvc?view=revision&revision=255970
 [2010-09-10 05:04 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: aharvey
 [2010-09-10 05:04 UTC] aharvey@php.net
Good catch. :)
 [2010-09-10 05:08 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=303249
Log: Fix bug #52802 (Out-of-date comment for
file_get_contents/php_stream_copy_to_mem) by updating the relevant comments.
 [2010-09-10 05:08 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2010-09-10 05:08 UTC] aharvey@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 01:01:28 2024 UTC