]> granicus.if.org Git - php/commitdiff
Fixed bug #45303 (Opening php:// wrapper in append mode results
authorArnaud Le Blanc <lbarnaud@php.net>
Mon, 3 Nov 2008 16:58:28 +0000 (16:58 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Mon, 3 Nov 2008 16:58:28 +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 39ffb86172a676a4d8d86c4e7521df514f7ad714..e96980b73f96c2520542fc016ff9ac3c2ea0637f 100644 (file)
@@ -239,6 +239,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