diff options
| author | Dmitry Stogov <dmitry@php.net> | 2008-06-11 09:02:09 +0000 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@php.net> | 2008-06-11 09:02:09 +0000 |
| commit | 6cd3a97ce20778d46ccc93e0bdcf788246a0058f (patch) | |
| tree | 194fc192cc21f1e4d6e14d37436c03e1d869d0e7 /ext | |
| parent | 32b6c60deae7193e68b21349a77f57d180dffad5 (diff) | |
| download | php-git-6cd3a97ce20778d46ccc93e0bdcf788246a0058f.tar.gz | |
closeder/readdir/rewinddir must work only with directories
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/standard/dir.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 2822a1fc83..bca2665080 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -260,6 +260,11 @@ PHP_FUNCTION(closedir) FETCH_DIRP(); + if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id); + RETURN_FALSE; + } + rsrc_id = dirp->rsrc_id; zend_list_delete(dirp->rsrc_id); @@ -360,6 +365,11 @@ PHP_FUNCTION(rewinddir) FETCH_DIRP(); + if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id); + RETURN_FALSE; + } + php_stream_rewinddir(dirp); } /* }}} */ @@ -374,6 +384,11 @@ PHP_NAMED_FUNCTION(php_if_readdir) FETCH_DIRP(); + if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id); + RETURN_FALSE; + } + if (php_stream_readdir(dirp, &entry)) { RETURN_STRINGL(entry.d_name, strlen(entry.d_name), 1); } |
