]> granicus.if.org Git - php/commitdiff
Added path truncation E_NOTICE to let people now when path resolving caused
authorIlia Alshanetsky <iliaa@php.net>
Tue, 10 Feb 2009 14:18:29 +0000 (14:18 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 10 Feb 2009 14:18:29 +0000 (14:18 +0000)
the file path to be truncated.

main/fopen_wrappers.c
main/streams/plain_wrapper.c

index 695ac3eacbd42528b89645099c741bf14d882690..7f0fe74599fd54ebed8f9ca10ea1d1c301962e4f 100644 (file)
@@ -528,7 +528,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);
+               }
                if (PG(safe_mode)) {
                        if (VCWD_STAT(trypath, &sb) == 0) {
                                /* file exists ... check permission */
index 0b0a3000b29c487a461a47674e6648c6461350aa..b2efa93f758496b6428a9eaa094d9e8e62b08721 100644 (file)
@@ -1324,7 +1324,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);
                
@@ -1385,7 +1387,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 %file", ptr, filename, MAXPATHLEN);
+               }
 
                if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir_ex(trypath, 0 TSRMLS_CC)) {
                        goto stream_skip;