Skip to content

Commit da0c65e

Browse files
committed
ext/standard: Validate scandir() sorting_order parameter
1 parent defc0be commit da0c65e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

ext/standard/dir.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,13 @@ PHP_FUNCTION(scandir)
537537
Z_PARAM_RESOURCE_OR_NULL(zcontext)
538538
ZEND_PARSE_PARAMETERS_END();
539539

540+
if (flags != PHP_SCANDIR_SORT_ASCENDING &&
541+
flags != PHP_SCANDIR_SORT_DESCENDING &&
542+
flags != PHP_SCANDIR_SORT_NONE) {
543+
zend_argument_value_error(2, "must be one of SCANDIR_SORT_ASCENDING, SCANDIR_SORT_DESCENDING, or SCANDIR_SORT_NONE");
544+
RETURN_THROWS();
545+
}
546+
540547
if (dirn_len < 1) {
541548
zend_argument_must_not_be_empty_error(1);
542549
RETURN_THROWS();

0 commit comments

Comments
 (0)