[PHP-CVS] cvs: php4 /ext/standard filestat.c

2003-02-27 Thread Ilia Alshanetsky
iliaa   Thu Feb 27 11:41:24 2003 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  Fixed bug #21410 (fixed handling of NULL or  files on Win32)
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.119 php4/ext/standard/filestat.c:1.120
--- php4/ext/standard/filestat.c:1.119  Sat Feb  8 22:49:41 2003
+++ php4/ext/standard/filestat.cThu Feb 27 11:41:23 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.119 2003/02/09 03:49:41 shane Exp $ */
+/* $Id: filestat.c,v 1.120 2003/02/27 16:41:23 iliaa Exp $ */
 
 #include php.h
 #include safe_mode.h
@@ -563,6 +563,10 @@
int rmask=S_IROTH, wmask=S_IWOTH, xmask=S_IXOTH; /* access rights defaults to 
other */
char *stat_sb_names[13]={dev, ino, mode, nlink, uid, gid, rdev,
  size, atime, mtime, ctime, blksize, blocks};
+
+   if (!filename_length) {
+   RETURN_FALSE;
+   }
 
if (PG(safe_mode) (!php_checkuid_ex(filename, NULL, 
CHECKUID_CHECK_FILE_AND_DIR, IS_EXISTS_CHECK(type) ? CHECKUID_NO_ERRORS : 0))) {
RETURN_FALSE;



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



[PHP-CVS] cvs: php4 /ext/standard filestat.c

2003-02-27 Thread Ilia Alshanetsky
iliaa   Thu Feb 27 15:38:01 2003 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  Fixed a bug that would cause filetype() to return unknown for 
  non-existent files on Win32.
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.120 php4/ext/standard/filestat.c:1.121
--- php4/ext/standard/filestat.c:1.120  Thu Feb 27 11:41:23 2003
+++ php4/ext/standard/filestat.cThu Feb 27 15:38:00 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.120 2003/02/27 16:41:23 iliaa Exp $ */
+/* $Id: filestat.c,v 1.121 2003/02/27 20:38:00 iliaa Exp $ */
 
 #include php.h
 #include safe_mode.h
@@ -608,9 +608,10 @@
}
efree(BG(CurrentStatFile));
BG(CurrentStatFile) = NULL;
-   if (!IS_LINK_OPERATION(type)) { /* Don't require success for 
link operation */
+#if HAVE_SYMLINK
+   if (!IS_LINK_OPERATION(type))  /* Don't require success for 
link operation */
+#endif
RETURN_FALSE;
-   }
}
}
 



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



[PHP-CVS] cvs: php4 /ext/standard filestat.c /main safe_mode.c safe_mode.h

2003-01-09 Thread Sara Golemon
pollita Thu Jan  9 16:57:45 2003 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
/php4/main  safe_mode.c safe_mode.h 
  Log:
  Bug #21531   file_exists() and other filestat functions throw errors when in safe 
mode and file/directory does not exist.
  Extended php_checkuid function to add flags field via rename to php_checkuid_ex 
with alias for BC in functions that do want safe mode errors thrown.
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.117 php4/ext/standard/filestat.c:1.118
--- php4/ext/standard/filestat.c:1.117  Sat Jan  4 19:56:17 2003
+++ php4/ext/standard/filestat.cThu Jan  9 16:57:44 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.117 2003/01/05 00:56:17 derick Exp $ */
+/* $Id: filestat.c,v 1.118 2003/01/09 21:57:44 pollita Exp $ */
 
 #include php.h
 #include safe_mode.h
@@ -564,7 +564,7 @@
char *stat_sb_names[13]={dev, ino, mode, nlink, uid, gid, rdev,
  size, atime, mtime, ctime, blksize, blocks};
 
-   if (PG(safe_mode) (!php_checkuid(filename, NULL, 
CHECKUID_CHECK_FILE_AND_DIR))) {
+   if (PG(safe_mode) (!php_checkuid_ex(filename, NULL, 
+CHECKUID_CHECK_FILE_AND_DIR, IS_EXISTS_CHECK(type) ? CHECKUID_NO_ERRORS : 0))) {
RETURN_FALSE;
}
 
Index: php4/main/safe_mode.c
diff -u php4/main/safe_mode.c:1.52 php4/main/safe_mode.c:1.53
--- php4/main/safe_mode.c:1.52  Tue Dec 31 10:58:54 2002
+++ php4/main/safe_mode.c   Thu Jan  9 16:57:45 2003
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf [EMAIL PROTECTED]|
+--+
  */
-/* $Id: safe_mode.c,v 1.52 2002/12/31 15:58:54 sebastian Exp $ */
+/* $Id: safe_mode.c,v 1.53 2003/01/09 21:57:45 pollita Exp $ */
 
 #include php.h
 
@@ -44,7 +44,7 @@
  * 5 - only check file
  */
 
-PHPAPI int php_checkuid(const char *filename, char *fopen_mode, int mode)
+PHPAPI int php_checkuid_ex(const char *filename, char *fopen_mode, int mode, int 
+flags)
 {
struct stat sb;
int ret, nofile=0;
@@ -85,12 +85,16 @@
ret = VCWD_STAT(path, sb);
if (ret  0) {
if (mode == CHECKUID_DISALLOW_FILE_NOT_EXISTS) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to 
access %s, filename);
+   if (flags  CHECKUID_NO_ERRORS == 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
+Unable to access %s, filename);
+   }
return 0;
} else if (mode == CHECKUID_ALLOW_FILE_NOT_EXISTS) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to 
access %s, filename);
+   if (flags  CHECKUID_NO_ERRORS == 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
+Unable to access %s, filename);
+   }
return 1;
-   }
+   } 
nofile = 1;
} else {
uid = sb.st_uid;
@@ -129,7 +133,9 @@
/* check directory */
ret = VCWD_STAT(path, sb);
if (ret  0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to access 
%s, filename);
+   if (flags  CHECKUID_NO_ERRORS == 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to 
+access %s, filename);
+   }
return 0;
}
duid = sb.st_uid;
@@ -162,15 +168,21 @@
gid = dgid;
filename = path;
}
-   
-   if (PG(safe_mode_gid)) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, SAFE MODE Restriction in 
effect.  The script whose uid/gid is %ld/%ld is not allowed to access %s owned by 
uid/gid %ld/%ld, php_getuid(), php_getgid(), filename, uid, gid);
-   } else {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, SAFE MODE Restriction in 
effect.  The script whose uid is %ld is not allowed to access %s owned by uid %ld, 
php_getuid(), filename, uid);
-   }   
+
+   if (flags  CHECKUID_NO_ERRORS == 0) {
+   if (PG(safe_mode_gid)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, SAFE MODE 
+Restriction in effect.  The script whose uid/gid is %ld/%ld is not allowed to access 
+%s owned by uid/gid %ld/%ld, php_getuid(), php_getgid(), filename, uid, gid);
+   } else {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, SAFE MODE 
+Restriction in effect.  The script whose uid is %ld is not allowed to access 

[PHP-CVS] cvs: php4 /ext/standard filestat.c

2003-01-04 Thread Derick Rethans
derick  Sat Jan  4 19:56:17 2003 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  - Fix some of the netware crap
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.116 php4/ext/standard/filestat.c:1.117
--- php4/ext/standard/filestat.c:1.116  Sat Jan  4 18:55:57 2003
+++ php4/ext/standard/filestat.cSat Jan  4 19:56:17 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.116 2003/01/04 23:55:57 derick Exp $ */
+/* $Id: filestat.c,v 1.117 2003/01/05 00:56:17 derick Exp $ */
 
 #include php.h
 #include safe_mode.h
@@ -710,25 +710,25 @@
php_error_docref(NULL TSRMLS_CC, E_NOTICE, Unknown file type (%d), 
BG(sb).st_modeS_IFMT);
RETURN_STRING(unknown, 1);
case FS_IS_W:
-   #ifndef NETWARE /* getuid is not available on NetWare */
+#ifndef NETWARE/* getuid is not available on NetWare */
if (getuid()==0) {
RETURN_TRUE; /* root */
}
-   #endif  /* NETWARE */
+#endif /* NETWARE */
RETURN_BOOL((BG(sb).st_mode  wmask) != 0);
case FS_IS_R:
-   #ifndef NETWARE /* getuid is not available on NetWare */
+#ifndef NETWARE/* getuid is not available on NetWare */
if (getuid()==0) {
RETURN_TRUE; /* root */
}
-   #endif  /* NETWARE */
+#endif /* NETWARE */
RETURN_BOOL((BG(sb).st_modermask)!=0);
case FS_IS_X:
-   #ifndef NETWARE /* getuid is not available on NetWare */
+#ifndef NETWARE/* getuid is not available on NetWare */
if (getuid()==0) {
xmask = S_IXROOT; /* root */
}
-   #endif  /* NETWARE */
+#endif /* NETWARE */
RETURN_BOOL((BG(sb).st_modexmask)!=0  !S_ISDIR(BG(sb).st_mode));
case FS_IS_FILE:
RETURN_BOOL(S_ISREG(BG(sb).st_mode));



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




[PHP-CVS] cvs: php4 /ext/standard filestat.c

2002-10-01 Thread Stefan Esser

sesser  Tue Oct  1 17:53:25 2002 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  repairing the chaos
  
  utime(filename, NULL) is not only valid but a MUST on linux if you are
  not the owner...
  
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.110 php4/ext/standard/filestat.c:1.111
--- php4/ext/standard/filestat.c:1.110  Mon Sep 23 10:59:24 2002
+++ php4/ext/standard/filestat.cTue Oct  1 17:53:25 2002
 -16,7 +16,7 
+--+
  */
 
-/* $Id: filestat.c,v 1.110 2002/09/23 14:59:24 sas Exp $ */
+/* $Id: filestat.c,v 1.111 2002/10/01 21:53:25 sesser Exp $ */
 
 #include php.h
 #include safe_mode.h
 -484,16 +484,20 
struct utimbuf *newtime = NULL;
int ac = ZEND_NUM_ARGS();
 
-   newtime = newtimebuf;
 
if (ac == 1  zend_get_parameters_ex(1, filename) != FAILURE) {
+#ifndef HAVE_UTIME_NULL
+   newtime = newtimebuf;
newtime-modtime = newtime-actime = time(NULL);
+#endif
} else if (ac == 2  zend_get_parameters_ex(2, filename, filetime) != 
FAILURE) {
convert_to_long_ex(filetime);
+   newtime = newtimebuf;
newtime-modtime = newtime-actime = Z_LVAL_PP(filetime);
} else if (ac == 3  zend_get_parameters_ex(3, filename, filetime, 
fileatime) != FAILURE) {
convert_to_long_ex(fileatime);
convert_to_long_ex(filetime);
+   newtime = newtimebuf;
newtime-actime = Z_LVAL_PP(fileatime);
newtime-modtime = Z_LVAL_PP(filetime);
} else {



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