From: Wez Furlong Date: Wed, 19 Mar 2003 00:17:15 +0000 (+0000) Subject: Sanity check for when a stream is requested to be persistent but the wrapper X-Git-Tag: RELEASE_0_5~415 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7379f47518bcffd57a829c74a0ea5fb86d9bcb0f;p=php Sanity check for when a stream is requested to be persistent but the wrapper does not respect the flag. --- diff --git a/main/streams/streams.c b/main/streams/streams.c index e2ff0bd709..b3dff8abb0 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -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;