From 756ab173890c13401ff862953adc6fd39b0782d2 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Thu, 30 Oct 2008 10:11:52 +0000 Subject: [PATCH] - MFH: Fixed bug #46426 (3rd parameter offset of stream_get_contents not works for "0") --- NEWS | 2 ++ ext/standard/streamsfuncs.c | 2 +- ext/standard/tests/streams/bug46426.phpt | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/streams/bug46426.phpt diff --git a/NEWS b/NEWS index 512bebf315..1d2d770527 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ PHP NEWS - Fixed ability to use "internal" heaps in extensions. (Arnaud, Dmitry) - Updated timezone database to version 2008.9. (Derick) +- Fixed bug #46426 (3rd parameter offset of stream_get_contents not works for + "0"). (Felipe) - Fixed bug #46406 (Unregistering nodeclass throws E_FATAL). (Rob) - Fixed bug #46389 (NetWare needs small patch for _timezone). (patch by guenter@php.net) diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 73a993b4d2..4a7644d3c3 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -406,7 +406,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-- + +--EXPECT-- +12345 +2345 +345 -- 2.50.1