1
0
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:
Ilia Alshanetsky
2009-02-10 14:22:19 +00:00
parent a7211f7457
commit 91aa9e2bf9
2 changed files with 9 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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;