daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: ext/standard/file.c
  2. ===================================================================
  3. --- ext/standard/file.c (revision 287717)
  4. +++ ext/standard/file.c (working copy)
  5. @@ -1364,16 +1364,25 @@
  6.  PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC)
  7.  {
  8.     int ret;
  9. +#ifdef PHP_WIN32
  10. +   char resolved_path_buff[MAXPATHLEN];
  11. +#endif
  12.  
  13.     if (PG(safe_mode) && (!php_checkuid(dir, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
  14.         return -1;
  15.     }
  16.  
  17. -   if (php_check_open_basedir(dir TSRMLS_CC)) {
  18. +#ifdef PHP_WIN32
  19. +   if (!VCWD_REALPATH(dir, resolved_path_buff)) {
  20.         return -1;
  21.     }
  22. +#endif
  23.  
  24. -   if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) < 0 && (options & REPORT_ERRORS)) {
  25. +   if (php_check_open_basedir(resolved_path_buff TSRMLS_CC)) {
  26. +       return -1;
  27. +   }
  28. +
  29. +   if ((ret = VCWD_MKDIR(resolved_path_buff, (mode_t)mode)) < 0 && (options & REPORT_ERRORS)) {
  30.         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
  31.     }
  32.  
  33. Index: win32/readdir.c
  34. ===================================================================
  35. --- win32/readdir.c (revision 287717)
  36. +++ win32/readdir.c (working copy)
  37. @@ -25,9 +25,15 @@
  38.     char *filespec;
  39.     HANDLE handle;
  40.     int index;
  41. +   char resolved_path_buff[MAXPATHLEN];
  42.  
  43. -   filespec = (char *)malloc(strlen(dir) + 2 + 1);
  44. -   strcpy(filespec, dir);
  45. +
  46. +   if (!VCWD_REALPATH(dir, resolved_path_buff)) {
  47. +       return NULL;
  48. +   }
  49. +
  50. +   filespec = (char *)malloc(strlen(resolved_path_buff) + 2 + 1);
  51. +   strcpy(filespec, resolved_path_buff);
  52.     index = strlen(filespec) - 1;
  53.     if (index >= 0 && (filespec[index] == '/' ||
  54.        (filespec[index] == '\\' && (index == 0 || !IsDBCSLeadByte(filespec[index-1])))))
  55. @@ -38,6 +44,7 @@
  56.     dp->offset = 0;
  57.     dp->finished = 0;
  58.  
  59. +
  60.     if ((handle = FindFirstFile(filespec, &(dp->fileinfo))) == INVALID_HANDLE_VALUE) {
  61.         DWORD err = GetLastError();
  62.         if (err == ERROR_NO_MORE_FILES) {
  63. @@ -48,7 +55,7 @@
  64.             return NULL;
  65.         }
  66.     }
  67. -   dp->dir = strdup(dir);
  68. +   dp->dir = strdup(resolved_path_buff);
  69.     dp->handle = handle;
  70.     free(filespec);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top