diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2002-10-28 00:28:11 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2002-10-28 00:28:11 +0000 |
commit | f76b9649cd224297e60b17c2de71a78b1966dc3e (patch) | |
tree | 4d305e72b13284ad506d1a1013cc4b5e70ec1b25 /main/streams.c | |
parent | 4a2efd53bfed9256b5f09d53ce6758529ce2bf00 (diff) | |
download | php-git-f76b9649cd224297e60b17c2de71a78b1966dc3e.tar.gz |
Fixed bug #20110.
Diffstat (limited to 'main/streams.c')
-rwxr-xr-x | main/streams.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/main/streams.c b/main/streams.c index cbbdba1124..a49c7633f4 100755 --- a/main/streams.c +++ b/main/streams.c @@ -1644,13 +1644,20 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, cha { FILE *fp; char *realpath = NULL; + struct stat st; + php_stream *ret; realpath = expand_filepath(filename, NULL TSRMLS_CC); fp = fopen(realpath, mode); if (fp) { - php_stream *ret = php_stream_fopen_from_file_rel(fp, mode); + /* this is done to prevent opening of anything other then regular files */ + if (fstat(fileno(fp), &st) == -1 || !S_ISREG(st.st_mode)) { + goto err; + } + + ret = php_stream_fopen_from_file_rel(fp, mode); if (ret) { if (opened_path) { @@ -1662,7 +1669,7 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, cha return ret; } - + err: fclose(fp); } efree(realpath); |