]> granicus.if.org Git - php/commitdiff
Sanity check for when a stream is requested to be persistent but the wrapper
authorWez Furlong <wez@php.net>
Wed, 19 Mar 2003 00:17:15 +0000 (00:17 +0000)
committerWez Furlong <wez@php.net>
Wed, 19 Mar 2003 00:17:15 +0000 (00:17 +0000)
does not respect the flag.

main/streams/streams.c

index e2ff0bd70949a4778cc09378480885a28fdc12d0..b3dff8abb0e55881534f37b9ff663740c305e398 100755 (executable)
@@ -1461,6 +1461,15 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio
                stream = wrapper->wops->stream_opener(wrapper,
                                path_to_open, mode, options ^ REPORT_ERRORS,
                                opened_path, context STREAMS_REL_CC TSRMLS_CC);
+       
+               /* if the caller asked for a persistent stream but the wrapper did not
+                * return one, force an error here */
+               if (stream && (options & STREAM_OPEN_PERSISTENT) && !stream->is_persistent) {
+                       php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC,
+                                       "wrapper does not support persistent streams");
+                       php_stream_close(stream);
+                       stream = NULL;
+               }
                
                if (stream) {
                        stream->wrapper = wrapper;