Skip to content

Commit fef9223

Browse files
author
Ilia Alshanetsky
committed
Fixed incorrect handling of files starting with a .
1 parent c33a695 commit fef9223

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

main/streams.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,16 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char
15181518
filename_length = strlen(filename);
15191519

15201520
/* Relative path open */
1521-
if (*filename == '.') {
1521+
if (*filename == '.' && (*(filename+1) == '/' || *(filename+1) == '.')) {
1522+
/* further checks, we could have ....... filenames */
1523+
ptr = filename + 1;
1524+
if (ptr == '.') {
1525+
while (*(++ptr) == '.');
1526+
if (ptr != '/') { /* not a relative path after all */
1527+
goto not_relative_path;
1528+
}
1529+
}
1530+
15221531

15231532
if (php_check_open_basedir(filename TSRMLS_CC)) {
15241533
return NULL;
@@ -1535,6 +1544,8 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char
15351544
* safe mode GID/UID checks
15361545
*/
15371546

1547+
not_relative_path:
1548+
15381549
/* Absolute path open */
15391550
if (IS_ABSOLUTE_PATH(filename, filename_length)) {
15401551

0 commit comments

Comments
 (0)