diff options
author | Felipe Pena <felipe@php.net> | 2008-10-30 10:09:22 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2008-10-30 10:09:22 +0000 |
commit | bfa5404e9050f602cee7850e725a8a70f21e28f3 (patch) | |
tree | d611ccd4e0be450d2684f6468ccb543f497a69ef | |
parent | 8107a8f121398f8c6e43593e4c7c152b0a84ce45 (diff) | |
download | php-git-bfa5404e9050f602cee7850e725a8a70f21e28f3.tar.gz |
- MFH: Fixed bug #46426 (3rd parameter offset of stream_get_contents not works for "0")
-rw-r--r-- | ext/standard/streamsfuncs.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/streams/bug46426.phpt | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index c3da25259e..505469c7dd 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -411,7 +411,7 @@ PHP_FUNCTION(stream_get_contents) php_stream_from_zval(stream, &zsrc); - if (pos > 0 && php_stream_seek(stream, pos, SEEK_SET) < 0) { + if (pos >= 0 && php_stream_seek(stream, pos, SEEK_SET) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos); RETURN_FALSE; } diff --git a/ext/standard/tests/streams/bug46426.phpt b/ext/standard/tests/streams/bug46426.phpt new file mode 100644 index 0000000000..05bc9c1e3c --- /dev/null +++ b/ext/standard/tests/streams/bug46426.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #46426 (3rd parameter offset of stream_get_contents not works for "0") +--FILE-- +<?php + +$tmp = tmpfile(); + +fwrite($tmp, "12345"); + +echo stream_get_contents($tmp, -1, 0); +echo "\n"; +echo stream_get_contents($tmp, -1, 1); +echo "\n"; +echo stream_get_contents($tmp, -1, 2); + +@unlink($tmp); + +?> +--EXPECT-- +12345 +2345 +345 |