*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);
+ }
if (PG(safe_mode)) {
if (VCWD_STAT(trypath, &sb) == 0) {
/* file exists ... check permission */
/* 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);
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 %file", ptr, filename, MAXPATHLEN);
+ }
if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir_ex(trypath, 0 TSRMLS_CC)) {
goto stream_skip;