]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #45303 (Opening php:// wrapper in append mode results
authorArnaud Le Blanc <lbarnaud@php.net>
Mon, 3 Nov 2008 16:58:53 +0000 (16:58 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Mon, 3 Nov 2008 16:58:53 +0000 (16:58 +0000)
in a warning)

ext/standard/tests/file/bug45303.phpt [new file with mode: 0644]
main/streams/plain_wrapper.c

diff --git a/ext/standard/tests/file/bug45303.phpt b/ext/standard/tests/file/bug45303.phpt
new file mode 100644 (file)
index 0000000..0a4b33b
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Bug #45303 (Opening php:// wrapper in append mode results in a warning)
+--FILE--
+<?php
+$fd = fopen("php://stdout","a");
+var_dump($fd);
+var_dump(fseek($fd, 1024*1024, SEEK_SET));
+?>
+--EXPECTF--
+resource(%d) of type (stream)
+
+Warning: fseek(): stream does not support seeking in %s
+int(-1)
index 6be46df215a537e7a20dab8a6191bd34f1d28e04..118acc7647ae49a094dde46ea07d024ea695b282 100644 (file)
@@ -242,6 +242,7 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha
 #ifdef ESPIPE
                        if (stream->position == (off_t)-1 && errno == ESPIPE) {
                                stream->position = 0;
+                               stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
                                self->is_pipe = 1;
                        }
 #endif