mirror of
https://github.com/php/php-src.git
synced 2026-03-29 03:32:20 +02:00
MFB: Added path truncation E_NOTICE to let people now when path resolving
caused the file path to be truncated.
This commit is contained in:
@@ -636,7 +636,9 @@ PHPAPI FILE *php_fopen_with_path(const char *filename, const char *mode, const c
|
||||
*end = '\0';
|
||||
end++;
|
||||
}
|
||||
snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename);
|
||||
if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) > MAXPATHLEN) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", ptr, filename, MAXPATHLEN);
|
||||
}
|
||||
|
||||
fp = php_fopen_and_set_opened_path(trypath, mode, opened_path TSRMLS_CC);
|
||||
if (fp) {
|
||||
|
||||
@@ -1289,7 +1289,9 @@ not_relative_path:
|
||||
/* getcwd() will return always return [DRIVE_LETTER]:/) on windows. */
|
||||
*(cwd+3) = '\0';
|
||||
|
||||
snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename);
|
||||
if (snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename) > MAXPATHLEN) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", cwd, filename, MAXPATHLEN);
|
||||
}
|
||||
|
||||
free(cwd);
|
||||
|
||||
@@ -1341,7 +1343,9 @@ not_relative_path:
|
||||
if (*ptr == '\0') {
|
||||
goto stream_skip;
|
||||
}
|
||||
snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename);
|
||||
if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) > MAXPATHLEN) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", ptr, filename, MAXPATHLEN);
|
||||
}
|
||||
|
||||
if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir_ex(trypath, 0 TSRMLS_CC)) {
|
||||
goto stream_skip;
|
||||
|
||||
Reference in New Issue
Block a user