[PHP-CVS] cvs: php-src /main php_open_temporary_file.c

2009-06-24 Thread Ilia Alshanetsky
iliaa   Thu Jun 25 01:35:15 2009 UTC

  Modified files:  
/php-src/main   php_open_temporary_file.c 
  Log:
  
  MFB: Handle instances where TMPDIR = 
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.c?r1=1.48r2=1.49diff_format=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.48 
php-src/main/php_open_temporary_file.c:1.49
--- php-src/main/php_open_temporary_file.c:1.48 Wed Jun 24 12:21:37 2009
+++ php-src/main/php_open_temporary_file.c  Thu Jun 25 01:35:15 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.48 2009/06/24 12:21:37 iliaa Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.49 2009/06/25 01:35:15 iliaa Exp $ */
 
 #include php.h
 
@@ -199,7 +199,7 @@
/* On Unix use the (usual) TMPDIR environment variable. */
{
char* s = getenv(TMPDIR);
-   if (s) {
+   if (s  *s) {
int len = strlen(s);
 
if (s[len - 1] == DEFAULT_SLASH) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main php_open_temporary_file.c

2007-08-10 Thread Antony Dovgal
tony2001Fri Aug 10 10:13:07 2007 UTC

  Modified files:  
/php-src/main   php_open_temporary_file.c 
  Log:
  resolve dir before calling mktemp/mkstemp
  this is tested by ext/standard/tests/file/tempnam_variation2.phpt
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.c?r1=1.43r2=1.44diff_format=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.43 
php-src/main/php_open_temporary_file.c:1.44
--- php-src/main/php_open_temporary_file.c:1.43 Sat Jul 21 01:41:55 2007
+++ php-src/main/php_open_temporary_file.c  Fri Aug 10 10:13:07 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.43 2007/07/21 01:41:55 jani Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.44 2007/08/10 10:13:07 tony2001 Exp $ */
 
 #include php.h
 
@@ -98,7 +98,8 @@
 {
char *trailing_slash;
char *opened_path;
-   int path_len = 0;
+   char cwd[MAXPATHLEN];
+   cwd_state new_state;
int fd = -1;
 #ifndef HAVE_MKSTEMP
int open_flags = O_CREAT | O_TRUNC | O_RDWR
@@ -108,25 +109,36 @@
;
 #endif
 
-   if (!path) {
+   if (!path || !path[0]) {
return -1;
}
 
-   path_len = strlen(path);
+   if (!VCWD_GETCWD(cwd, MAXPATHLEN)) {
+   cwd[0] = '\0';
+   }
+
+   new_state.cwd = strdup(cwd);
+   new_state.cwd_length = strlen(cwd);
+
+   if (virtual_file_ex(new_state, path, NULL, CWD_REALPATH)) {
+   free(new_state.cwd);
+   return -1;
+   }
 
-   if (!path_len || IS_SLASH(path[path_len - 1])) {
+   if (IS_SLASH(new_state.cwd[new_state.cwd_length - 1])) {
trailing_slash = ;
} else {
trailing_slash = /;
}
 
-   if (spprintf(opened_path, 0, %s%s%sXX, path, trailing_slash, 
pfx) = MAXPATHLEN) {
+   if (spprintf(opened_path, 0, %s%s%sXX, new_state.cwd, 
trailing_slash, pfx) = MAXPATHLEN) {
efree(opened_path);
+   free(new_state.cwd);
return -1;
}
 
 #ifdef PHP_WIN32
-   if (GetTempFileName(path, pfx, 0, opened_path)) {
+   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... */
VCWD_CHMOD(opened_path, 0600);
@@ -144,6 +156,7 @@
} else {
*opened_path_p = opened_path;
}
+   free(new_state.cwd);
return fd;
 }
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main php_open_temporary_file.c

2007-02-06 Thread Antony Dovgal
tony2001Tue Feb  6 17:35:42 2007 UTC

  Modified files:  
/php-src/main   php_open_temporary_file.c 
  Log:
  use strdup()
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.c?r1=1.41r2=1.42diff_format=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.41 
php-src/main/php_open_temporary_file.c:1.42
--- php-src/main/php_open_temporary_file.c:1.41 Sat Feb  3 14:57:24 2007
+++ php-src/main/php_open_temporary_file.c  Tue Feb  6 17:35:42 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.41 2007/02/03 14:57:24 helly Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.42 2007/02/06 17:35:42 tony2001 Exp $ */
 
 #include php.h
 
@@ -194,12 +194,12 @@
 #ifdef P_tmpdir
/* Use the standard default temporary directory. */
if (P_tmpdir) {
-   temporary_directory = P_tmpdir;
+   temporary_directory = strdup(P_tmpdir);
return temporary_directory;
}
 #endif
/* Shouldn't ever(!) end up here ... last ditch default. */
-   temporary_directory = /tmp;
+   temporary_directory = strdup(/tmp);
return temporary_directory;
 #endif
 }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main php_open_temporary_file.c

2006-09-28 Thread Antony Dovgal
tony2001Thu Sep 28 08:26:19 2006 UTC

  Modified files:  
/php-src/main   php_open_temporary_file.c 
  Log:
  fix compile warning
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.c?r1=1.37r2=1.38diff_format=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.37 
php-src/main/php_open_temporary_file.c:1.38
--- php-src/main/php_open_temporary_file.c:1.37 Wed Sep 27 23:44:34 2006
+++ php-src/main/php_open_temporary_file.c  Thu Sep 28 08:26:19 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.37 2006/09/27 23:44:34 iliaa Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.38 2006/09/28 08:26:19 tony2001 Exp $ */
 
 #include php.h
 
@@ -206,7 +206,7 @@
 PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char 
**opened_path_p TSRMLS_DC)
 {
int fd;
-   char *temp_dir = php_get_temporary_directory();
+   const char *temp_dir = php_get_temporary_directory();
 
if (!pfx) {
pfx = tmp.;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main php_open_temporary_file.c

2006-09-27 Thread Ilia Alshanetsky
iliaa   Wed Sep 27 23:44:34 2006 UTC

  Modified files:  
/php-src/main   php_open_temporary_file.c 
  Log:
  MFB: Fixed bug #38963 (Fixed a possible open_basedir bypass in tempnam()).
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_open_temporary_file.c?r1=1.36r2=1.37diff_format=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.36 
php-src/main/php_open_temporary_file.c:1.37
--- php-src/main/php_open_temporary_file.c:1.36 Tue May 23 23:22:16 2006
+++ php-src/main/php_open_temporary_file.c  Wed Sep 27 23:44:34 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.36 2006/05/23 23:22:16 iliaa Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.37 2006/09/27 23:44:34 iliaa Exp $ */
 
 #include php.h
 
@@ -206,6 +206,7 @@
 PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char 
**opened_path_p TSRMLS_DC)
 {
int fd;
+   char *temp_dir = php_get_temporary_directory();
 
if (!pfx) {
pfx = tmp.;
@@ -214,11 +215,19 @@
*opened_path_p = NULL;
}
 
+   if (!dir || *dir == '\0') {
+   if (temp_dir  *temp_dir != '\0'  
!php_check_open_basedir(temp_dir TSRMLS_CC)) {
+   return php_do_open_temporary_file(temp_dir, pfx, 
opened_path_p TSRMLS_CC);
+   } else {
+   return -1;
+   }
+   }
+
/* Try the directory given as parameter. */
fd = php_do_open_temporary_file(dir, pfx, opened_path_p TSRMLS_CC);
if (fd == -1) {
/* Use default temporary directory. */
-   fd = php_do_open_temporary_file(php_get_temporary_directory(), 
pfx, opened_path_p TSRMLS_CC);
+   fd = php_do_open_temporary_file(temp_dir, pfx, opened_path_p 
TSRMLS_CC);
}
return fd;
 }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main php_open_temporary_file.c

2006-05-23 Thread Ilia Alshanetsky
iliaa   Tue May 23 23:22:16 2006 UTC

  Modified files:  
/php-src/main   php_open_temporary_file.c 
  Log:
  MFB: Fixed handling of extremely long paths inside tempnam() function.
  
  
http://cvs.php.net/viewcvs.cgi/php-src/main/php_open_temporary_file.c?r1=1.35r2=1.36diff_format=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.35 
php-src/main/php_open_temporary_file.c:1.36
--- php-src/main/php_open_temporary_file.c:1.35 Sun Jan  1 13:09:57 2006
+++ php-src/main/php_open_temporary_file.c  Tue May 23 23:22:16 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.35 2006/01/01 13:09:57 sniper Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.36 2006/05/23 23:22:16 iliaa Exp $ */
 
 #include php.h
 
@@ -114,17 +114,16 @@
 
path_len = strlen(path);
 
-   if (!(opened_path = emalloc(MAXPATHLEN))) {
-   return -1;
-   }
-
if (!path_len || IS_SLASH(path[path_len - 1])) {
trailing_slash = ;
} else {
trailing_slash = /;
}
 
-   (void)snprintf(opened_path, MAXPATHLEN, %s%s%sXX, path, 
trailing_slash, pfx);
+   if (spprintf(opened_path, 0, %s%s%sXX, path, trailing_slash, 
pfx) = MAXPATHLEN) {
+   efree(opened_path);
+   return -1;
+   }
 
 #ifdef PHP_WIN32
if (GetTempFileName(path, pfx, 0, opened_path)) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main php_open_temporary_file.c

2005-02-23 Thread Anantha Kesari H Y
hyanantha   Wed Feb 23 05:54:07 2005 EDT

  Modified files:  
/php-src/main   php_open_temporary_file.c 
  Log:
  NetWare LibC has mkstemp implementation
  
  
http://cvs.php.net/diff.php/php-src/main/php_open_temporary_file.c?r1=1.31r2=1.32ty=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.31 
php-src/main/php_open_temporary_file.c:1.32
--- php-src/main/php_open_temporary_file.c:1.31 Thu Oct  7 08:22:16 2004
+++ php-src/main/php_open_temporary_file.c  Wed Feb 23 05:54:06 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.31 2004/10/07 12:22:16 hyanantha Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.32 2005/02/23 10:54:06 hyanantha Exp $ */
 
 #include php.h
 
@@ -106,9 +106,6 @@
 #endif
;
 #endif
-#ifdef NETWARE
-char *file_path = NULL;
-#endif
 
if (!path) {
return -1;
@@ -133,12 +130,6 @@
VCWD_CHMOD(opened_path, 0600);
fd = VCWD_OPEN_MODE(opened_path, open_flags, 0600);
}
-#elif defined(NETWARE)
-   /* Using standard mktemp() implementation for NetWare */
-   file_path = mktemp(opened_path);
-   if (file_path) {
-   fd = VCWD_OPEN(file_path, open_flags);
-   }
 #elif defined(HAVE_MKSTEMP)
fd = mkstemp(opened_path);
 #else

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main php_open_temporary_file.c

2004-10-07 Thread Anantha Kesari H Y
hyanantha   Thu Oct  7 08:22:21 2004 EDT

  Modified files:  
/php-src/main   php_open_temporary_file.c 
  Log:
  removed unwanted NEW_LIBC checks for NETWARE and removing custom mktemp.h as LibC 
itself supports mkstemp functionality
  
  
http://cvs.php.net/diff.php/php-src/main/php_open_temporary_file.c?r1=1.30r2=1.31ty=u
Index: php-src/main/php_open_temporary_file.c
diff -u php-src/main/php_open_temporary_file.c:1.30 
php-src/main/php_open_temporary_file.c:1.31
--- php-src/main/php_open_temporary_file.c:1.30 Mon Mar 29 16:44:07 2004
+++ php-src/main/php_open_temporary_file.c  Thu Oct  7 08:22:16 2004
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_open_temporary_file.c,v 1.30 2004/03/29 21:44:07 wez Exp $ */
+/* $Id: php_open_temporary_file.c,v 1.31 2004/10/07 12:22:16 hyanantha Exp $ */
 
 #include php.h
 
@@ -31,18 +31,12 @@
 #include win32/winutil.h
 #elif defined(NETWARE)
 #ifdef USE_WINSOCK
-/*#include ws2nlm.h*/
 #include novsock2.h
 #else
 #include sys/socket.h
 #endif
-#ifdef NEW_LIBC
 #include sys/param.h
 #else
-#include netware/param.h
-#endif
-#include netware/mktemp.h
-#else
 #include sys/param.h
 #include sys/socket.h
 #include netinet/in.h

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php