php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch patch-main_open_temporary_file for Unknown/Other Function Bug #63968

Patch version 2013-01-11 20:06 UTC

Return to Bug #63968 | Download this patch
Patch Revisions:

Developer: web@bartwell.ru

*** main/php_open_temporary_file.c.orig	2013-01-11 20:33:42.000000000 +0400
--- main/php_open_temporary_file.c	2013-01-11 21:17:44.000000000 +0400
***************
*** 101,113 ****
  	char cwd[MAXPATHLEN];
  	cwd_state new_state;
  	int fd = -1;
! #ifndef HAVE_MKSTEMP
! 	int open_flags = O_CREAT | O_TRUNC | O_RDWR
! #ifdef PHP_WIN32
! 		| _O_BINARY
! #endif
! 		;
! #endif
  
  	if (!path || !path[0]) {
  		return -1;
--- 101,107 ----
  	char cwd[MAXPATHLEN];
  	cwd_state new_state;
  	int fd = -1;
! 	int open_flags = O_CREAT | O_TRUNC | O_RDWR;
  
  	if (!path || !path[0]) {
  		return -1;
***************
*** 144,169 ****
  		return -1;
  	}
  
- #ifdef PHP_WIN32
- 
- 	if (GetTempFileName(new_state.cwd, pfx, 0, opened_path)) {
- 		/* Some versions of windows set the temp file to be read-only,
- 		 * which means that opening it will fail... */
- 		if (VCWD_CHMOD(opened_path, 0600)) {
- 			efree(opened_path);
- 			free(new_state.cwd);
- 			return -1;
- 		}
- 		fd = VCWD_OPEN_MODE(opened_path, open_flags, 0600);
- 	}
- 
- #elif defined(HAVE_MKSTEMP)
- 	fd = mkstemp(opened_path);
- #else
  	if (mktemp(opened_path)) {
! 		fd = VCWD_OPEN(opened_path, open_flags);
  	}
- #endif
  
  	if (fd == -1 || !opened_path_p) {
  		efree(opened_path);
--- 138,146 ----
  		return -1;
  	}
  
  	if (mktemp(opened_path)) {
! 		fd = VCWD_OPEN_MODE(opened_path, open_flags, 0660);
  	}
  
  	if (fd == -1 || !opened_path_p) {
  		efree(opened_path);
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Mar 04 13:01:25 2021 UTC