[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2006-04-14 Thread Sara Golemon
pollita Fri Apr 14 17:47:51 2006 UTC

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH (r-1.436) copy() should not disrespect open_basedir on source file
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/file.c?r1=1.279.2.70&r2=1.279.2.71&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.70 
php-src/ext/standard/file.c:1.279.2.71
--- php-src/ext/standard/file.c:1.279.2.70  Sun Mar 27 15:53:59 2005
+++ php-src/ext/standard/file.c Fri Apr 14 17:47:51 2006
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.70 2005/03/27 15:53:59 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.71 2006/04/14 17:47:51 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2143,7 +2143,7 @@
int ret = FAILURE;
 
srcstream = php_stream_open_wrapper(src, "rb",
-   STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS,
+   ENFORCE_SAFE_MODE | REPORT_ERRORS,
NULL);
 
if (!srcstream)

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2005-03-27 Thread Ilia Alshanetsky
iliaa   Sun Mar 27 10:54:00 2005 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH: revert copy patch.
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.69&r2=1.279.2.70&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.69 
php-src/ext/standard/file.c:1.279.2.70
--- php-src/ext/standard/file.c:1.279.2.69  Wed Mar  2 22:31:59 2005
+++ php-src/ext/standard/file.c Sun Mar 27 10:53:59 2005
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.69 2005/03/03 03:31:59 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.70 2005/03/27 15:53:59 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2141,12 +2141,6 @@
 {
php_stream *srcstream = NULL, *deststream = NULL;
int ret = FAILURE;
-   struct stat src_s, dest_s;
-
-   /* safety check to ensure that source & destination files are not the 
same file */
-   if (stat(src, &src_s) || (stat(dest, &dest_s) == 0 && src_s.st_ino == 
dest_s.st_ino)) {
-   return ret;
-   }
 
srcstream = php_stream_open_wrapper(src, "rb",
STREAM_DISABLE_OPEN_BASEDIR | REPORT_ERRORS,

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2004-10-28 Thread Andi Gutmans
andiThu Oct 28 20:38:45 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  - [PATCH] Bug fix for #29770, but for PHP 4.3.9 (Vladimir Zidar)
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.64&r2=1.279.2.65&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.64 php-src/ext/standard/file.c:1.279.2.65
--- php-src/ext/standard/file.c:1.279.2.64  Thu Oct 28 01:05:57 2004
+++ php-src/ext/standard/file.c Thu Oct 28 20:38:44 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.64 2004/10/28 05:05:57 tony2001 Exp $ */
+/* $Id: file.c,v 1.279.2.65 2004/10/29 00:38:44 andi Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1189,7 +1189,7 @@
zval **arg1, **arg2;
FILE *fp;
char *p, *tmp = NULL;
-   char *b, buf[1024];
+   char *b, *buf = 0;
php_stream *stream;
 
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == 
FAILURE) {
@@ -1212,10 +1212,11 @@
b = NULL;
}
}
+   
if (b) {
-   snprintf(buf, sizeof(buf), "%s%s", PG(safe_mode_exec_dir), b);
+   spprintf(&buf, 0, "%s%s", PG(safe_mode_exec_dir), b);
} else {
-   snprintf(buf, sizeof(buf), "%s/%s", PG(safe_mode_exec_dir), 
Z_STRVAL_PP(arg1));
+   spprintf(&buf, 0, "%s/%s", PG(safe_mode_exec_dir), 
Z_STRVAL_PP(arg1));
}
 
tmp = php_escape_shell_cmd(buf);
@@ -1225,8 +1226,12 @@
if (!fp) {
php_error_docref2(NULL TSRMLS_CC, buf, p, E_WARNING, "%s", 
strerror(errno));
efree(p);
+   efree(buf);
RETURN_FALSE;
}
+   
+   efree(buf);
+
} else {
fp = VCWD_POPEN(Z_STRVAL_PP(arg1), p);
if (!fp) {

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2004-10-27 Thread Antony Dovgal
tony2001Thu Oct 28 01:05:57 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  fix Win32 & Netware build
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.63&r2=1.279.2.64&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.63 php-src/ext/standard/file.c:1.279.2.64
--- php-src/ext/standard/file.c:1.279.2.63  Wed Oct 27 08:01:20 2004
+++ php-src/ext/standard/file.c Thu Oct 28 01:05:57 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.63 2004/10/27 12:01:20 tony2001 Exp $ */
+/* $Id: file.c,v 1.279.2.64 2004/10/28 05:05:57 tony2001 Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1917,6 +1917,7 @@
struct stat sb;
if (php_copy_file(old_name, new_name TSRMLS_CC) == SUCCESS) {
if (VCWD_STAT(old_name, &sb) == 0) {
+#if !defined(TSRM_WIN32) && !defined(NETWARE)
if (VCWD_CHMOD(new_name, sb.st_mode)) {
if (errno == EPERM) {
php_error_docref2(NULL 
TSRMLS_CC, old_name, new_name, E_WARNING, "%s", strerror(errno));
@@ -1935,6 +1936,7 @@
php_error_docref2(NULL TSRMLS_CC, 
old_name, new_name, E_WARNING, "%s", strerror(errno));
RETURN_FALSE;
}
+#endif
VCWD_UNLINK(old_name);
RETURN_TRUE;
}

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2004-10-27 Thread Antony Dovgal
tony2001Wed Oct 27 08:01:20 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH: fix bug #30388 (rename across filesystems loses ownership and permission info)
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.62&r2=1.279.2.63&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.62 php-src/ext/standard/file.c:1.279.2.63
--- php-src/ext/standard/file.c:1.279.2.62  Fri Sep 24 09:07:18 2004
+++ php-src/ext/standard/file.c Wed Oct 27 08:01:20 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.62 2004/09/24 13:07:18 derick Exp $ */
+/* $Id: file.c,v 1.279.2.63 2004/10/27 12:01:20 tony2001 Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1914,9 +1914,30 @@
if (ret == -1) {
 #ifdef EXDEV
if (errno == EXDEV) {
-   if (php_copy_file(old_name, new_name TSRMLS_CC) == SUCCESS) {
-   VCWD_UNLINK(old_name);
-   RETURN_TRUE;
+   struct stat sb;
+   if (php_copy_file(old_name, new_name TSRMLS_CC) == SUCCESS) {
+   if (VCWD_STAT(old_name, &sb) == 0) {
+   if (VCWD_CHMOD(new_name, sb.st_mode)) {
+   if (errno == EPERM) {
+   php_error_docref2(NULL 
TSRMLS_CC, old_name, new_name, E_WARNING, "%s", strerror(errno));
+   VCWD_UNLINK(old_name);
+   RETURN_TRUE;
+   }
+   php_error_docref2(NULL TSRMLS_CC, 
old_name, new_name, E_WARNING, "%s", strerror(errno));
+   RETURN_FALSE;
+   }
+   if (VCWD_CHOWN(new_name, sb.st_uid, 
sb.st_gid)) {
+   if (errno == EPERM) {
+   php_error_docref2(NULL 
TSRMLS_CC, old_name, new_name, E_WARNING, "%s", strerror(errno));
+   VCWD_UNLINK(old_name);
+   RETURN_TRUE;
+   }
+   php_error_docref2(NULL TSRMLS_CC, 
old_name, new_name, E_WARNING, "%s", strerror(errno));
+   RETURN_FALSE;
+   }
+   VCWD_UNLINK(old_name);
+   RETURN_TRUE;
+   }
}
}
 #endif

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2004-05-14 Thread Ilia Alshanetsky
iliaa   Fri May 14 12:12:06 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH: Fixed possible memory leak inside popen().
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.59&r2=1.279.2.60&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.59 php-src/ext/standard/file.c:1.279.2.60
--- php-src/ext/standard/file.c:1.279.2.59  Fri Apr  2 11:54:44 2004
+++ php-src/ext/standard/file.c Fri May 14 12:12:06 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.59 2004/04/02 16:54:44 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.60 2004/05/14 16:12:06 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1224,6 +1224,7 @@
 
if (!fp) {
php_error_docref2(NULL TSRMLS_CC, buf, p, E_WARNING, "%s", 
strerror(errno));
+   efree(p);
RETURN_FALSE;
}
} else {

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /ext/standard/tests/file fgetcsv.phpt

2004-04-02 Thread Ilia Alshanetsky
iliaa   Fri Apr  2 11:54:45 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
/php-src/ext/standard/tests/filefgetcsv.phpt 
  Log:
  Fixed bug #27730.
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.58&r2=1.279.2.59&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.58 php-src/ext/standard/file.c:1.279.2.59
--- php-src/ext/standard/file.c:1.279.2.58  Fri Mar 26 15:53:09 2004
+++ php-src/ext/standard/file.c Fri Apr  2 11:54:44 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.58 2004/03/26 20:53:09 abies Exp $ */
+/* $Id: file.c,v 1.279.2.59 2004/04/02 16:54:44 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2331,6 +2331,11 @@
}   \
 }
 
+   if (!(e - s)) {
+   CSV_ADD_ENTRY(s, e, s);
+   goto done;
+   }
+
 csv_start:
if (!enclosure || !(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure, 
0))) {
 no_enclosure:
http://cvs.php.net/diff.php/php-src/ext/standard/tests/file/fgetcsv.phpt?r1=1.1.2.2&r2=1.1.2.3&ty=u
Index: php-src/ext/standard/tests/file/fgetcsv.phpt
diff -u php-src/ext/standard/tests/file/fgetcsv.phpt:1.1.2.2 
php-src/ext/standard/tests/file/fgetcsv.phpt:1.1.2.3
--- php-src/ext/standard/tests/file/fgetcsv.phpt:1.1.2.2Thu Jan 29 09:35:34 
2004
+++ php-src/ext/standard/tests/file/fgetcsv.phptFri Apr  2 11:54:44 2004
@@ -23,7 +23,8 @@
'aaa"aaa","bbb"bbb',
'aaa"aaa""",bbb',
'aaa"\\"a","bbb"',
-   '""'
+   '""',
+   ''
);
 
$file = dirname(__FILE__) . 'fgetcsv.csv';
@@ -161,3 +162,7 @@
   [0]=>
   string(0) ""
 }
+array(1) {
+  [0]=>
+  string(0) ""
+}

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2004-03-26 Thread Ard Biesheuvel
abies   Fri Mar 26 15:53:10 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  Alignment fix
  http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.57&r2=1.279.2.58&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.57 php-src/ext/standard/file.c:1.279.2.58
--- php-src/ext/standard/file.c:1.279.2.57  Thu Jan 29 09:35:34 2004
+++ php-src/ext/standard/file.c Fri Mar 26 15:53:09 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.57 2004/01/29 14:35:34 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.58 2004/03/26 20:53:09 abies Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -179,7 +179,7 @@
 #endif
 
REGISTER_INI_ENTRIES();
-   
+
REGISTER_LONG_CONSTANT("SEEK_SET", SEEK_SET, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SEEK_CUR", SEEK_CUR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SEEK_END", SEEK_END, CONST_CS | CONST_PERSISTENT);
@@ -196,11 +196,11 @@
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_REDIRECTED",  
PHP_STREAM_NOTIFY_REDIRECTED,   CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_PROGRESS",
PHP_STREAM_NOTIFY_PROGRESS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_FAILURE", 
PHP_STREAM_NOTIFY_FAILURE,  CONST_CS | CONST_PERSISTENT);
-   
+
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_INFO",   
PHP_STREAM_NOTIFY_SEVERITY_INFO, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_WARN",   
PHP_STREAM_NOTIFY_SEVERITY_WARN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_ERR",
PHP_STREAM_NOTIFY_SEVERITY_ERR,  CONST_CS | CONST_PERSISTENT);
-   
+
 #ifdef HAVE_FNMATCH
REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_CS | 
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FNM_PATHNAME", FNM_PATHNAME, CONST_CS | 
CONST_PERSISTENT);
@@ -267,7 +267,7 @@
Z_LVAL_PP(arg3) = 1;
} else {
RETURN_FALSE;
-   }   
+   }
}
RETURN_TRUE;
 }
@@ -396,7 +396,7 @@
/* For BC */
php_strtolower(name, strlen(name));
if (have_content) {
-   add_assoc_string(return_value, name, value, 
0); 
+   add_assoc_string(return_value, name, value, 0);
} else {
add_assoc_string(return_value, name, 
empty_string, 0);
}
@@ -407,7 +407,7 @@
}
 
name = value = NULL;
-   
+
/* Reset all of our flags */
in_tag = looking_for_val = 0;
have_name = saw_name = 0;
@@ -445,7 +445,7 @@
return;
}
 
-   stream = php_stream_open_wrapper(filename, "rb", 
+   stream = php_stream_open_wrapper(filename, "rb",
(use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | 
REPORT_ERRORS,
NULL);
if (!stream) {
@@ -472,7 +472,7 @@
}
 
php_stream_close(stream);
-   
+
 }
 /* }}} */
 
@@ -498,7 +498,7 @@
return;
}
 
-   stream = php_stream_open_wrapper(filename, "rb", 
+   stream = php_stream_open_wrapper(filename, "rb",
(use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | 
REPORT_ERRORS,
NULL);
if (!stream) {
@@ -511,16 +511,16 @@
if ((target_len = php_stream_copy_to_mem(stream, &target_buf, 
PHP_STREAM_COPY_ALL, 0))) {
s = target_buf;
e = target_buf + target_len;
-   
+
if (!(p = php_stream_locate_eol(stream, target_buf, target_len 
TSRMLS_CC))) {
p = e;
goto parse_eol;
}
-   
+
if (stream->flags & PHP_STREAM_FLAG_EOL_MAC) {
eol_marker = '\r';
-   }   
-   
+   }
+
do {
p++;
 parse_eol:
@@ -533,7 +533,7 @@
}
s = p;
} while ((p = memchr(p, eol_marker, (e-p;
-   
+
/* handle any left overs of files without new lines */
if (s != e) {
p = e;
@@ -543,7 +543,7 @@
 
if (target_buf) {
efree(target_buf);
-   }   
+   }
php_s

[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /ext/standard/tests/file fgetcsv.phpt

2004-01-29 Thread Ilia Alshanetsky
iliaa   Thu Jan 29 09:35:35 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard/tests/filefgetcsv.phpt 
/php-src/ext/standard   file.c 
  Log:
  Fix for a possible crash in fgetcsv(). (Patch by Moriyoshi Koizumi)
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/tests/file/fgetcsv.phpt?r1=1.1.2.1&r2=1.1.2.2&ty=u
Index: php-src/ext/standard/tests/file/fgetcsv.phpt
diff -u php-src/ext/standard/tests/file/fgetcsv.phpt:1.1.2.1 
php-src/ext/standard/tests/file/fgetcsv.phpt:1.1.2.2
--- php-src/ext/standard/tests/file/fgetcsv.phpt:1.1.2.1Sun Jan 18 22:55:44 
2004
+++ php-src/ext/standard/tests/file/fgetcsv.phptThu Jan 29 09:35:34 2004
@@ -22,7 +22,8 @@
'aaa,"bbb   "',
'aaa"aaa","bbb"bbb',
'aaa"aaa""",bbb',
-   'aaa"\\"a","bbb"'
+   'aaa"\\"a","bbb"',
+   '""'
);
 
$file = dirname(__FILE__) . 'fgetcsv.csv';
@@ -156,3 +157,7 @@
   [1]=>
   string(3) "bbb"
 }
+array(1) {
+  [0]=>
+  string(0) ""
+}
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.56&r2=1.279.2.57&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.56 php-src/ext/standard/file.c:1.279.2.57
--- php-src/ext/standard/file.c:1.279.2.56  Tue Jan 20 21:33:22 2004
+++ php-src/ext/standard/file.c Thu Jan 29 09:35:34 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.56 2004/01/21 02:33:22 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.57 2004/01/29 14:35:34 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2408,11 +2408,9 @@
e--;
}
 
-   if (e - s) {
-   buf2 = erealloc(buf2, buf2_len + (e - s) + 1);
-   memcpy(buf2 + buf2_len, s, (e - s));
-   buf2_len += e - s;
-   }
+   buf2 = erealloc(buf2, buf2_len + (e - s) + 1);
+   memcpy(buf2 + buf2_len, s, (e - s));
+   buf2_len += e - s;
 enclosure_done:
_php_fgetcsv_trim_enclosed(buf2, &buf2_len, enclosure);
CSV_ADD_ENTRY(buf2, buf2_len, 0);

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2004-01-19 Thread Ilia Alshanetsky
iliaa   Mon Jan 19 13:40:47 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH: Fixed bug #26967 (make various file operations return FALSE on error).
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.54&r2=1.279.2.55&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.54 php-src/ext/standard/file.c:1.279.2.55
--- php-src/ext/standard/file.c:1.279.2.54  Sun Jan 18 13:46:31 2004
+++ php-src/ext/standard/file.c Mon Jan 19 13:40:45 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.54 2004/01/18 18:46:31 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.55 2004/01/19 18:40:45 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -120,6 +120,13 @@
 #endif
 
 /* }}} */
+
+#define PHP_STREAM_TO_ZVAL(stream, arg) \
+   php_stream_from_zval_no_verify(stream, arg); \
+   if (stream == NULL) {   \
+   RETURN_FALSE;   \
+   }
+
 /* {{{ ZTS-stuff / Globals / Prototypes */
 
 /* sharing globals is *evil* */
@@ -233,7 +240,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)&fd, 1) == FAILURE)   
 {
RETURN_FALSE;
@@ -606,7 +613,7 @@
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
array_init(return_value);

@@ -1086,7 +1093,7 @@
RETURN_FALSE;
}
 
-   php_stream_from_zval(stream, &zstream);
+   PHP_STREAM_TO_ZVAL(stream, &zstream);

filter = php_stream_filter_create(filtername, filterparams, filterparamslen, 
php_stream_is_persistent(stream) TSRMLS_CC);
if (filter == NULL)
@@ -1162,7 +1169,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
if (!stream->is_persistent) {
zend_list_delete(stream->rsrc_id);
} else {
@@ -1251,7 +1258,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
zend_list_delete(stream->rsrc_id);
RETURN_LONG(FG(pclose_ret));
@@ -1269,7 +1276,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
if (php_stream_eof(stream)) {
RETURN_TRUE;
@@ -1291,7 +1298,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
convert_to_long_ex(arg2);
block = Z_LVAL_PP(arg2);
@@ -1326,7 +1333,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, socket);
+   PHP_STREAM_TO_ZVAL(stream, socket);
 
convert_to_long_ex(seconds);
t.tv_sec = Z_LVAL_PP(seconds);
@@ -1363,11 +1370,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval_no_verify(stream, arg1);
-   if (stream == NULL) {
-   /* want a false return value here */
-   goto exit_failed;
-   }
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
if (argc == 1) {
/* ask streams to give us a buffer of an appropriate size */
@@ -1421,7 +1424,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
buf = emalloc(2 * sizeof(char));
 
@@ -1471,7 +1474,7 @@
break;
}
 
-   php_stream_from_zval(stream, fd);
+   PHP_STREAM_TO_ZVAL(stream, fd);
 
convert_to_long_ex(bytes);
len = Z_LVAL_PP(bytes);
@@ -1589,7 +1592,7 @@
break;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
if (!arg3 && PG(magic_quotes_runtime)) {
buffer = estrndup(Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2));
@@ -1617,7 +1620,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
ret = php_stream_flush(stream);
if (ret) {
@@ -1648,7 +1651,7 @@
break;
}

-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);

convert_to_long_ex(arg2);
buff = Z_LVAL_PP(arg2);
@@ -1675,7 +1678,7 @@
WRONG_PARAM_COUNT;
}
 
-   php_stream_from_zval(stream, arg1);
+   PHP_STREAM_TO_ZVAL(stream, arg1);
 
if (-1 == php_stream_rewind(stream)) {
RETURN_FALSE;
@@ -1696,7 +1699,7 @@
  

Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /ext/standard/tests/file bug26634.phpt

2004-01-18 Thread Moriyoshi Koizumi
I have little time atm, and actually it's bout time I was in bed :)
Could you do it for me?
Thanks,
Moriyoshi
On 2004/01/19, at 5:36, Ilia Alshanetsky wrote:

Certainly, if you want to do so, please go ahead, if not I'll do it 
myself
either tonight or tomorrow.

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


Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /ext/standard/tests/file bug26634.phpt

2004-01-18 Thread Ilia Alshanetsky
Certainly, if you want to do so, please go ahead, if not I'll do it myself 
either tonight or tomorrow.

Ilia

On January 18, 2004 03:34 pm, Moriyoshi Koizumi wrote:
> Isn't it a good idea to add test cases for every issue that was
> revealed since the last patch?
>
> Moriyoshi
>
> On 2004/01/19, at 3:46, Ilia Alshanetsky wrote:
> > iliaa   Sun Jan 18 13:46:33 2004 EDT
> >
> >   Modified files:  (Branch: PHP_4_3)
> > /php-src/ext/standard   file.c
> > /php-src/ext/standard/tests/filebug26634.phpt
> >   Log:
> >   Corrections for various fgetcsv() issues.

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



Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /ext/standard/tests/file bug26634.phpt

2004-01-18 Thread Moriyoshi Koizumi
Isn't it a good idea to add test cases for every issue that was
revealed since the last patch?
Moriyoshi

On 2004/01/19, at 3:46, Ilia Alshanetsky wrote:

iliaa		Sun Jan 18 13:46:33 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c
/php-src/ext/standard/tests/filebug26634.phpt
  Log:
  Corrections for various fgetcsv() issues.
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /ext/standard/tests/file bug26634.phpt

2004-01-18 Thread Ilia Alshanetsky
iliaa   Sun Jan 18 13:46:33 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
/php-src/ext/standard/tests/filebug26634.phpt 
  Log:
  Corrections for various fgetcsv() issues.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.53 php-src/ext/standard/file.c:1.279.2.54
--- php-src/ext/standard/file.c:1.279.2.53  Wed Jan 14 09:31:27 2004
+++ php-src/ext/standard/file.c Sun Jan 18 13:46:31 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.53 2004/01/14 14:31:27 wez Exp $ */
+/* $Id: file.c,v 1.279.2.54 2004/01/18 18:46:31 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2159,7 +2159,7 @@
 }
 /* }}} */
 
-static char *_php_fgetcsv_find_enclosure(char *start, int len, char enclosure)
+static char *_php_fgetcsv_find_enclosure(char *start, int len, char enclosure, int 
end)
 {
char *s=start, *p, *e=start+len;
 
@@ -2177,12 +2177,60 @@
continue;
}
}
+   if (end) {
+   int i = 0;
+   while (e > p && *p == enclosure) {
+   s = ++p;
+   i++;
+   }
+   if (!(i % 2)) {
+   continue;
+   } else {
+   p--;
+   }
+   }
return p;
}
 
return NULL;
 }
 
+static void _php_fgetcsv_trim_enclosed(char *buf2, int *buf2_len, char enclosure)
+{
+   if (memchr(buf2, enclosure, *buf2_len)) {
+   int esc = 0, enc_c = 0, pos = 0;
+   while (pos < *buf2_len) {
+   if (*(buf2 + pos) == '\\') {
+   esc = !esc;
+   enc_c = 0;
+   } else if (*(buf2 + pos) == enclosure) {
+   if (esc) {
+   esc = 0;
+   } else if (enc_c) {
+   enc_c = 0;
+   memmove(buf2 + pos, buf2 + pos + 1, *buf2_len 
- pos - 1);
+   (*buf2_len)--;
+   continue;
+   } else if (!esc) {
+   enc_c = 2;
+   }
+   } else {
+   if (enc_c == 2) {
+   memmove(buf2 + pos - 1, buf2 + pos, *buf2_len 
- pos);
+   (*buf2_len)--;
+   enc_c--;
+   }
+   esc = 0;
+   }
+   pos++;
+   }
+   if (enc_c && *(buf2 + pos - 1) == enclosure) {
+   (*buf2_len)--;
+   }
+   }
+   buf2[*buf2_len] = '\0';
+}
+
 /* {{{ proto array fgetcsv(resource fp, int length [, string delimiter [, string 
enclosure]])
Get line from file pointer and parse for CSV fields */
 PHP_FUNCTION(fgetcsv)
@@ -2264,29 +2312,23 @@
while (isspace((int)*(unsigned char *)s) && *s != delimiter && s < re) {
s++;
}
+
/* strip trailing spaces */
-   while (--e >= s && isspace((int)*(unsigned char *)(e)) && *e != delimiter);
+   while (--e >= s && (*e == '\n' || *e == '\r') && *e != delimiter);
e++;
 
array_init(return_value);
 
-#define CSV_ADD_ENTRY(os, es, st)  {   \
-   int tmp_sl = es - st;   \
-   char *tmp_s=os; \
-   if (tmp_sl) {   \
-   while (isspace((int)*(unsigned char *)tmp_s)) { \
-   tmp_s++;\
-   tmp_sl--;   \
-   }   \
-   }   \
-   if (tmp_sl) {   \
-   add_next_index_stringl(return_value, tmp_s, tmp_sl, 1); \
+#define CSV_ADD_ENTRY(os, es, st) {\
+   if (es - st) {  \
+   add_next_index_stringl(return_value, os, es - st, 1);   \
} else {\
add_next_index_string(return_value, "", 1); \
}   \
-}  \
+}
 
-   if (!enclosure || !(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure))) {
+csv_start:
+   if (!enclosure || !(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure, 
0))) {
 no_enclosure:
while ((p = memchr(s, delimiter, (e - s {
CSV_ADD_ENTRY(s, p, s);
@@ -2303,12 +2345,23 @@
}
 
p++;
-   if (*s == enclosure) {
+   /* strip leading spaces */
+   while (isspace((int)*(unsigned char *)s) && *s != delimite

[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2004-01-02 Thread Ilia Alshanetsky
iliaa   Fri Jan  2 19:50:02 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH: s/then/than/
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.51 php-src/ext/standard/file.c:1.279.2.52
--- php-src/ext/standard/file.c:1.279.2.51  Thu Jan  1 19:58:15 2004
+++ php-src/ext/standard/file.c Fri Jan  2 19:50:01 2004
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.51 2004/01/02 00:58:15 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.52 2004/01/03 00:50:01 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1375,7 +1375,7 @@
len = Z_LVAL_PP(arg2);
 
if (len <= 0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter 
must be greater then 0.");
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter 
must be greater than 0.");
RETURN_FALSE;
}
 
@@ -1472,7 +1472,7 @@
convert_to_long_ex(bytes);
len = Z_LVAL_PP(bytes);
if (len <= 0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be 
greater then 0.");
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be 
greater than 0.");
RETURN_FALSE;
}
 
@@ -2137,7 +2137,7 @@
convert_to_long_ex(arg2);
len = Z_LVAL_PP(arg2);
if (len <= 0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be 
greater then 0.");
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be 
greater than 0.");
RETURN_FALSE;
}
 

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-28 Thread Ilia Alshanetsky
iliaa   Sun Dec 28 14:31:49 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  Boundry check.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.49 php-src/ext/standard/file.c:1.279.2.50
--- php-src/ext/standard/file.c:1.279.2.49  Tue Dec 23 06:06:42 2003
+++ php-src/ext/standard/file.c Sun Dec 28 14:31:48 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.49 2003/12/23 11:06:42 moriyoshi Exp $ */
+/* $Id: file.c,v 1.279.2.50 2003/12/28 19:31:48 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2340,7 +2340,7 @@
goto enclosure;
}
} else {
-   while (e < re && *(e - 1) == enclosure) {
+   while (e < re && e > s && *(e - 1) == enclosure) {
e--;
}
 

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-23 Thread Moriyoshi Koizumi
moriyoshi   Tue Dec 23 06:06:43 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  Oops.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.48 php-src/ext/standard/file.c:1.279.2.49
--- php-src/ext/standard/file.c:1.279.2.48  Tue Dec 23 06:02:26 2003
+++ php-src/ext/standard/file.c Tue Dec 23 06:06:42 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.48 2003/12/23 11:02:26 moriyoshi Exp $ */
+/* $Id: file.c,v 1.279.2.49 2003/12/23 11:06:42 moriyoshi Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2261,7 +2261,7 @@
s++;
}
/* strip trailing spaces */
-   while (e >= s && isspace((int)*(unsigned char *)(--e)) && *e != delimiter);
+   while (--e >= s && isspace((int)*(unsigned char *)(e)) && *e != delimiter);
e++;
 
array_init(return_value);

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-23 Thread Moriyoshi Koizumi
moriyoshi   Tue Dec 23 06:02:27 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  Fix fgetcsv()'s null line handling.
  # Thanks Takeshi Nakamura for reporting this bug.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.47 php-src/ext/standard/file.c:1.279.2.48
--- php-src/ext/standard/file.c:1.279.2.47  Mon Dec 22 16:03:54 2003
+++ php-src/ext/standard/file.c Tue Dec 23 06:02:26 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.47 2003/12/22 21:03:54 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.48 2003/12/23 11:02:26 moriyoshi Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2257,11 +2257,11 @@
re = e = buf + buf_len;
 
/* strip leading spaces */
-   while (isspace((int)*(unsigned char *)s) && *s != delimiter) {
+   while (isspace((int)*(unsigned char *)s) && *s != delimiter && s < re) {
s++;
}
/* strip trailing spaces */
-   while (isspace((int)*(unsigned char *)(--e)) && *e != delimiter);
+   while (e >= s && isspace((int)*(unsigned char *)(--e)) && *e != delimiter);
e++;
 
array_init(return_value);

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-22 Thread Ilia Alshanetsky
iliaa   Mon Dec 22 16:03:55 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  Fixed memory leak.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.46 php-src/ext/standard/file.c:1.279.2.47
--- php-src/ext/standard/file.c:1.279.2.46  Mon Dec 15 13:53:25 2003
+++ php-src/ext/standard/file.c Mon Dec 22 16:03:54 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.46 2003/12/15 18:53:25 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.47 2003/12/22 21:03:54 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2190,7 +2190,7 @@
 
zval **fd, **bytes, **p_delim, **p_enclosure;
int len, buf_len;
-   char *buf, *p, *s, *e, *re;
+   char *buf, *p, *s, *e, *re, *buf2=NULL;
php_stream *stream;
 
switch(ZEND_NUM_ARGS()) {
@@ -2289,7 +2289,7 @@
s = p + 1;
}
} else {
-   char *p2=NULL, *buf2=NULL;
+   char *p2=NULL;
int buf2_len=0;
 enclosure:
/* handle complete fields before the enclosure */
@@ -2351,9 +2351,7 @@
}
 enclosure_done:
CSV_ADD_ENTRY(buf2, buf2_len, 0);
-   if (buf2) {
-   efree(buf2);
-   }
+
goto done;
}
}
@@ -2362,6 +2360,9 @@
CSV_ADD_ENTRY(s, e, s);
}
 done:
+   if (buf2) {
+   efree(buf2);
+   }
efree(buf);
 }
 /* }}} */

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /ext/standard/tests/file bug26634.phpt test4.csv

2003-12-15 Thread Ilia Alshanetsky
iliaa   Mon Dec 15 13:53:27 2003 EDT

  Added files: (Branch: PHP_4_3)
/php-src/ext/standard/tests/filebug26634.phpt test4.csv 

  Modified files:  
/php-src/ext/standard   file.c 
  Log:
  Fixed bug #26634 & added test case.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.45 php-src/ext/standard/file.c:1.279.2.46
--- php-src/ext/standard/file.c:1.279.2.45  Fri Dec 12 20:44:24 2003
+++ php-src/ext/standard/file.c Mon Dec 15 13:53:25 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.45 2003/12/13 01:44:24 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.46 2003/12/15 18:53:25 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2266,16 +2266,17 @@
 
array_init(return_value);
 
-#define CSV_ADD_ENTRY(s, es, st)   {   \
-   int len = es - st;  \
-   if (len) {  \
-   while (isspace((int)*(unsigned char *)s)) { \
-   s++;\
-   len--;  \
+#define CSV_ADD_ENTRY(os, es, st)  {   \
+   int tmp_sl = es - st;   \
+   char *tmp_s=os; \
+   if (tmp_sl) {   \
+   while (isspace((int)*(unsigned char *)tmp_s)) { \
+   tmp_s++;\
+   tmp_sl--;   \
}   \
}   \
-   if (len) {  \
-   add_next_index_stringl(return_value, s, len, 1);\
+   if (tmp_sl) {   \
+   add_next_index_stringl(return_value, tmp_s, tmp_sl, 1); \
} else {\
add_next_index_string(return_value, "", 1); \
}   \

Index: php-src/ext/standard/tests/file/bug26634.phpt
+++ php-src/ext/standard/tests/file/bug26634.phpt

Index: php-src/ext/standard/tests/file/test4.csv
+++ php-src/ext/standard/tests/file/test4.csv

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-12 Thread Ilia Alshanetsky
iliaa   Fri Dec 12 20:44:25 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  More fgetcsv() fixes.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.44 php-src/ext/standard/file.c:1.279.2.45
--- php-src/ext/standard/file.c:1.279.2.44  Fri Dec 12 14:25:33 2003
+++ php-src/ext/standard/file.c Fri Dec 12 20:44:24 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.44 2003/12/12 19:25:33 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.45 2003/12/13 01:44:24 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2266,7 +2266,7 @@
 
array_init(return_value);
 
-#define CSV_ADD_ENTRY(s, es, st, copy) {   \
+#define CSV_ADD_ENTRY(s, es, st)   {   \
int len = es - st;  \
if (len) {  \
while (isspace((int)*(unsigned char *)s)) { \
@@ -2275,7 +2275,7 @@
}   \
}   \
if (len) {  \
-   add_next_index_stringl(return_value, s, len, copy); \
+   add_next_index_stringl(return_value, s, len, 1);\
} else {\
add_next_index_string(return_value, "", 1); \
}   \
@@ -2284,29 +2284,23 @@
if (!enclosure || !(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure))) {
 no_enclosure:
while ((p = memchr(s, delimiter, (e - s {
-   CSV_ADD_ENTRY(s, p, s, 1);
+   CSV_ADD_ENTRY(s, p, s);
s = p + 1;
}
} else {
-   char *p2=NULL, *buf2;
-   int buf2_len;
+   char *p2=NULL, *buf2=NULL;
+   int buf2_len=0;
 enclosure:
/* handle complete fields before the enclosure */
while (s < p && (p2 = memchr(s, delimiter, (p - s {
-   CSV_ADD_ENTRY(s, p2, s, 1);
+   CSV_ADD_ENTRY(s, p2, s);
s = p2 + 1;
}
 
-   if ((p - s)) {
-   buf2_len = p - s;
-   buf2 = emalloc(buf2_len + 1);
-   memcpy(buf2, s, buf2_len);
-   } else {
-   buf2 = NULL;
-   buf2_len = 0;
+   p++;
+   if (*s == enclosure) {
s++;
}
-   p++;
 
/* try to find end of enclosure */
while (!(p2 = _php_fgetcsv_find_enclosure(p, (e - p), enclosure))) {
@@ -2336,8 +2330,8 @@
memcpy(buf2 + buf2_len, p2, (p - p2));
buf2_len += (p - p2);
}
-   buf2[buf2_len] = '\0';
-   CSV_ADD_ENTRY(buf2, buf2_len, 0, 0);
+   CSV_ADD_ENTRY(buf2, buf2_len, 0);
+   buf2_len = 0;
 
if (!(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure))) 
{
goto no_enclosure;
@@ -2355,15 +2349,18 @@
buf2_len += (e - s);
}
 enclosure_done:
-   s = e = NULL;
-   buf2[buf2_len] = '\0';
-   CSV_ADD_ENTRY(buf2, buf2_len, 0, 0);
+   CSV_ADD_ENTRY(buf2, buf2_len, 0);
+   if (buf2) {
+   efree(buf2);
+   }
+   goto done;
}
}
 
if (s < e) {
-   CSV_ADD_ENTRY(s, e, s, 1);
+   CSV_ADD_ENTRY(s, e, s);
}
+done:
efree(buf);
 }
 /* }}} */

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-12 Thread Ilia Alshanetsky
iliaa   Fri Dec 12 14:25:34 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  For BC reasons we need to do ltrim() on csv entries.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.43 php-src/ext/standard/file.c:1.279.2.44
--- php-src/ext/standard/file.c:1.279.2.43  Sun Dec  7 16:55:16 2003
+++ php-src/ext/standard/file.c Fri Dec 12 14:25:33 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.43 2003/12/07 21:55:16 moriyoshi Exp $ */
+/* $Id: file.c,v 1.279.2.44 2003/12/12 19:25:33 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2266,10 +2266,25 @@
 
array_init(return_value);
 
+#define CSV_ADD_ENTRY(s, es, st, copy) {   \
+   int len = es - st;  \
+   if (len) {  \
+   while (isspace((int)*(unsigned char *)s)) { \
+   s++;\
+   len--;  \
+   }   \
+   }   \
+   if (len) {  \
+   add_next_index_stringl(return_value, s, len, copy); \
+   } else {\
+   add_next_index_string(return_value, "", 1); \
+   }   \
+}  \
+
if (!enclosure || !(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure))) {
 no_enclosure:
while ((p = memchr(s, delimiter, (e - s {
-   add_next_index_stringl(return_value, s, (p - s), 1);
+   CSV_ADD_ENTRY(s, p, s, 1);
s = p + 1;
}
} else {
@@ -2278,7 +2293,7 @@
 enclosure:
/* handle complete fields before the enclosure */
while (s < p && (p2 = memchr(s, delimiter, (p - s {
-   add_next_index_stringl(return_value, s, (p2 - s), 1);
+   CSV_ADD_ENTRY(s, p2, s, 1);
s = p2 + 1;
}
 
@@ -2322,7 +2337,7 @@
buf2_len += (p - p2);
}
buf2[buf2_len] = '\0';
-   add_next_index_stringl(return_value, buf2, buf2_len, 0);
+   CSV_ADD_ENTRY(buf2, buf2_len, 0, 0);
 
if (!(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure))) 
{
goto no_enclosure;
@@ -2342,12 +2357,12 @@
 enclosure_done:
s = e = NULL;
buf2[buf2_len] = '\0';
-   add_next_index_stringl(return_value, buf2, buf2_len, 0);
+   CSV_ADD_ENTRY(buf2, buf2_len, 0, 0);
}
}
 
if (s < e) {
-   add_next_index_stringl(return_value, s, (e - s), 1);
+   CSV_ADD_ENTRY(s, e, s, 1);
}
efree(buf);
 }

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



Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-07 Thread Moriyoshi Koizumi
On 2003/12/08, at 8:50, Ilia Alshanetsky wrote:

While I cannot speak for behavior of the win32 libc library I've just  
tested a
simple C program with positive & negative ranges for the values of  
isspace().
In glibc 2.2.X, 2.3.X, libc4 (FreeBSD 4.7), libc5 (FreeBSD 5.1) the  
function
works properly without long winded casts.
See also those patches on the libc in the FreeBSD tree:

[1.2 - 1.3]
* Move more stuff out to XPG4
* Handle negative chars inside runetype/tolower/toupper
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/locale/ 
runetype.c.diff?r1=1.2&r2=1.3&f=h

[1.3 - 1.4]
*  Remove half-dancing solution for signed chars to help finding
   POSIXly-incorrect programs.
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/locale/ 
runetype.c.diff?r1=1.3&r2=1.4&f=h

And I already noted that the GNU libc kindly takes care of
non-standard-compliant codes.
Moriyoshi

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


Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-07 Thread Moriyoshi Koizumi
On 2003/12/08, at 8:50, Ilia Alshanetsky wrote:

While I cannot speak for behavior of the win32 libc library I've just 
tested a
simple C program with positive & negative ranges for the values of 
isspace().
In glibc 2.2.X, 2.3.X, libc4 (FreeBSD 4.7), libc5 (FreeBSD 5.1) the 
function
works properly without long winded casts.
The vector-based table varies by the locale setting. And it really 
matters
on win32. Why do you still want to keep it wrong? Even though you get
the correct values, it's wrong usage anyway. If you don't like ugly 
casts,
just use unsigned char in the first place, as I already mentioned.

Moriyoshi

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


Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-07 Thread Ilia Alshanetsky
On December 7, 2003 06:17 pm, Moriyoshi Koizumi wrote:
> Nope. Regardless of the range the function covers, it may return an
> unwanted
> value because the function is likely backed by a simple vector and a
> negative
> argument may make it refer to a point out of the valid address space.

While I cannot speak for behavior of the win32 libc library I've just tested a 
simple C program with positive & negative ranges for the values of isspace(). 
In glibc 2.2.X, 2.3.X, libc4 (FreeBSD 4.7), libc5 (FreeBSD 5.1) the function 
works properly without long winded casts.

Ilia

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



Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-07 Thread Moriyoshi Koizumi
On 2003/12/08, at 8:15, Ilia Alshanetsky wrote:

Correct me if I am wrong but as far as I know the issue you mention 
only
affects tolower(), toupper() and is* functions that operate on letters.
Functions such as isspace() are safe since their limited character set 
only
covers a very limited range of characters that are not affected by the
behavior you've described.
Nope. Regardless of the range the function covers, it may return an 
unwanted
value because the function is likely backed by a simple vector and a 
negative
argument may make it refer to a point out of the valid address space.

Moriyoshi

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


Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-07 Thread Ilia Alshanetsky
Correct me if I am wrong but as far as I know the issue you mention only 
affects tolower(), toupper() and is* functions that operate on letters. 
Functions such as isspace() are safe since their limited character set only 
covers a very limited range of characters that are not affected by the 
behavior you've described.

Ilia

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-07 Thread Moriyoshi Koizumi
moriyoshi   Sun Dec  7 16:55:17 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  Those casts are really necessary.
  # Heads up; please be careful using is*() functions. The function of that kind
  # takes an integer value as its argument and expects the value to be range of
  # 0-255 as a parameter. So if you pass a plain char value to it, the char
  # value will be converted implicitly to an integer value of the range
  # -128 ~ 127, which will end up with an unwanted result, most likely with
  # non-ASCII characters. This has been considered to be a big flaw in the
  # specification of the ctype functions. However, the malfunction is not
  # reproducible with the recent versions of the GNU C library because it is
  # made to deal with such exceptional cases, while Microsoft's C library
  # and several standard C libraries of BSD origin aren't.
  #
  # See also bug #10896, #12127, #18318, and #21689.
  #
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.42 php-src/ext/standard/file.c:1.279.2.43
--- php-src/ext/standard/file.c:1.279.2.42  Sat Dec  6 17:07:00 2003
+++ php-src/ext/standard/file.c Sun Dec  7 16:55:16 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.42 2003/12/06 22:07:00 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.43 2003/12/07 21:55:16 moriyoshi Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2257,11 +2257,11 @@
re = e = buf + buf_len;
 
/* strip leading spaces */
-   while (isspace(*s) && *s != delimiter) {
+   while (isspace((int)*(unsigned char *)s) && *s != delimiter) {
s++;
}
/* strip trailing spaces */
-   while (isspace(*(--e)) && *e != delimiter);
+   while (isspace((int)*(unsigned char *)(--e)) && *e != delimiter);
e++;
 
array_init(return_value);
@@ -2305,7 +2305,7 @@
s = p = buf;
re = e = buf + buf_len;
/* strip trailing spaces */
-   while (isspace(*(--e)) && *e != delimiter);
+   while (isspace((int)*(unsigned char *)(--e)) && *e != 
delimiter);
e++;
}
 

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



Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-06 Thread Moriyoshi Koizumi
Hi,

+   /* strip leading spaces */
+   while (isspace(*s) && *s != delimiter) {
+   s++;
+   }
+   /* strip trailing spaces */
+   while (isspace(*(--e)) && *e != delimiter);
+   e++;

+   if (php_stream_get_line(stream, buf, len, &buf_len) == NULL) {
+   goto enclosure_done;
+   }
+   s = p = buf;
+   re = e = buf + buf_len;
+   /* strip trailing spaces */
+   while (isspace(*(--e)) && *e != delimiter);
+   e++;
+   }
Looks like cast is missing at each isspace()..?

Moriyoshi

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


[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-12-06 Thread Ilia Alshanetsky
iliaa   Sat Dec  6 17:07:02 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  Fixed memory corruption occuring in fgetcsv() on certain files.
  
  Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.41 php-src/ext/standard/file.c:1.279.2.42
--- php-src/ext/standard/file.c:1.279.2.41  Fri Nov 28 13:33:18 2003
+++ php-src/ext/standard/file.c Sat Dec  6 17:07:00 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.41 2003/11/28 18:33:18 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.42 2003/12/06 22:07:00 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2155,19 +2155,42 @@
 }
 /* }}} */
 
+static char *_php_fgetcsv_find_enclosure(char *start, int len, char enclosure)
+{
+   char *s=start, *p, *e=start+len;
+
+   while (e > s && (p = memchr(s, enclosure, (e - s {
+   if (p > s && *(p - 1) == '\\') {/* check escape characters */
+   int enc_cnt=0;
+   char *pp = p - 1;
+
+   while (pp >= s && *pp == '\\') {
+   enc_cnt++;
+   pp--;
+   }
+   if ((enc_cnt % 2)) {
+   s = p + 1;
+   continue;
+   }
+   }
+   return p;
+   }
+
+   return NULL;
+}
+
 /* {{{ proto array fgetcsv(resource fp, int length [, string delimiter [, string 
enclosure]])
Get line from file pointer and parse for CSV fields */
 PHP_FUNCTION(fgetcsv)
 {
-   char *temp, *tptr, *bptr, *lineEnd;
char delimiter = ',';   /* allow this to be set as parameter */
char enclosure = '"';   /* allow this to be set as parameter */
 
/* first section exactly as php_fgetss */
 
zval **fd, **bytes, **p_delim, **p_enclosure;
-   int len, temp_len, buf_len;
-   char *buf;
+   int len, buf_len;
+   char *buf, *p, *s, *e, *re;
php_stream *stream;
 
switch(ZEND_NUM_ARGS()) {
@@ -2208,13 +2231,11 @@
 
if (ZEND_NUM_ARGS() >= 4) {
convert_to_string_ex(p_enclosure);
-   /* Make sure that there is at least one character in string */
-   if (Z_STRLEN_PP(p_enclosure) < 1) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "enclosure must be 
a character");
-   RETURN_FALSE;
+   if (Z_STRLEN_PP(p_enclosure) < 1) { /* no enclosure */
+   enclosure = 0;
+   } else { /* use first character from string */
+   enclosure = Z_STRVAL_PP(p_enclosure)[0];
}
-   /* use first character from string */
-   enclosure = Z_STRVAL_PP(p_enclosure)[0];
}
 
php_stream_from_zval(stream, fd);
@@ -2227,159 +2248,107 @@
}
 
buf = emalloc(len + 1);
-   /* needed because recv/read/gzread doesnt set null char at end */
-   memset(buf, 0, len + 1);
 
if (php_stream_get_line(stream, buf, len, &buf_len) == NULL) {
efree(buf);
RETURN_FALSE;
}
+   s = buf;
+   re = e = buf + buf_len;
 
-   /* Now into new section that parses buf for delimiter/enclosure fields */
+   /* strip leading spaces */
+   while (isspace(*s) && *s != delimiter) {
+   s++;
+   }
+   /* strip trailing spaces */
+   while (isspace(*(--e)) && *e != delimiter);
+   e++;
 
-   /* Strip trailing space from buf, saving end of line in case required for 
enclosure field */
+   array_init(return_value);
 
-   lineEnd = emalloc(len + 1);
-   bptr = buf;
-   tptr = buf + buf_len -1;
-   while ( isspace((int)*(unsigned char *)tptr) && (*tptr!=delimiter) && (tptr > 
bptr) ) tptr--;
-   tptr++;
-   strcpy(lineEnd, tptr);
-
-   /* add single space - makes it easier to parse trailing null field */
-   *tptr++ = ' ';
-   *tptr = 0;
-
-   /* reserve workspace for building each individual field */
-
-   temp_len = len;
-   temp = emalloc(temp_len + 1);   /* unlikely but possible! */
-   tptr = temp;
+   if (!enclosure || !(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure))) {
+no_enclosure:
+   while ((p = memchr(s, delimiter, (e - s {
+   add_next_index_stringl(return_value, s, (p - s), 1);
+   s = p + 1;
+   }
+   } else {
+   char *p2=NULL, *buf2;
+   int buf2_len;
+enclosure:
+   /* handle complete fields before the enclosure */
+   while (s < p && (p2 = memchr(s, delimiter, (p - s {
+   add_next_index_stringl(return_value, s, (p2 - s), 1);
+ 

[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-11-28 Thread Ilia Alshanetsky
iliaa   Fri Nov 28 13:33:20 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH: More memory leak fixes for stream contexts.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.40 php-src/ext/standard/file.c:1.279.2.41
--- php-src/ext/standard/file.c:1.279.2.40  Sun Nov 23 20:43:59 2003
+++ php-src/ext/standard/file.c Fri Nov 28 13:33:18 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.40 2003/11/24 01:43:59 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.41 2003/11/28 18:33:18 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -614,6 +614,7 @@
MAKE_STD_ZVAL(newval);
*newval = *(stream->wrapperdata);
zval_copy_ctor(newval);
+   INIT_PZVAL(newval);
 
add_assoc_zval(return_value, "wrapper_data", newval);
}
@@ -994,10 +995,9 @@
context = decode_context_param(zcontext TSRMLS_CC);
ZEND_VERIFY_RESOURCE(context);
 
-   array_init(return_value);
*return_value = *context->options;
zval_copy_ctor(return_value);
-   
+   INIT_PZVAL(return_value);
 }
 /* }}} */
 

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c file.h

2003-09-29 Thread Stanislav Malyshev
stasMon Sep 29 10:04:16 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c file.h 
  Log:
  allow realpath() for win32 non-ZTS
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.36 php-src/ext/standard/file.c:1.279.2.37
--- php-src/ext/standard/file.c:1.279.2.36  Tue Sep  9 21:03:41 2003
+++ php-src/ext/standard/file.c Mon Sep 29 10:04:16 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.36 2003/09/10 01:03:41 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.37 2003/09/29 14:04:16 stas Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2364,7 +2364,7 @@
 /* }}} */
 
 
-#if (!defined(PHP_WIN32) && !defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) 
|| defined(ZTS)
+#if (!defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS)
 /* {{{ proto string realpath(string path)
Return the resolved path */
 PHP_FUNCTION(realpath)
Index: php-src/ext/standard/file.h
diff -u php-src/ext/standard/file.h:1.70.2.4 php-src/ext/standard/file.h:1.70.2.5
--- php-src/ext/standard/file.h:1.70.2.4Sun Jun 29 19:29:49 2003
+++ php-src/ext/standard/file.h Mon Sep 29 10:04:16 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: file.h,v 1.70.2.4 2003/06/29 23:29:49 edink Exp $ */
+/* $Id: file.h,v 1.70.2.5 2003/09/29 14:04:16 stas Exp $ */
 
 /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
 
@@ -63,8 +63,10 @@
 PHP_FUNCTION(flock);
 PHP_FUNCTION(fd_set);
 PHP_FUNCTION(fd_isset);
-#if (!defined(PHP_WIN32) && !defined(__BEOS__) && HAVE_REALPATH) || defined(ZTS)
+#if (!defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS)
 PHP_FUNCTION(realpath);
+#endif
+#ifdef HAVE_FNMATCH
 PHP_FUNCTION(fnmatch);
 #endif
 PHP_NAMED_FUNCTION(php_if_ftruncate);

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-09-09 Thread Ilia Alshanetsky
iliaa   Tue Sep  9 21:03:42 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  #if -> #ifdef
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.35 php-src/ext/standard/file.c:1.279.2.36
--- php-src/ext/standard/file.c:1.279.2.35  Tue Sep  9 20:22:19 2003
+++ php-src/ext/standard/file.c Tue Sep  9 21:03:41 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.35 2003/09/10 00:22:19 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.36 2003/09/10 01:03:41 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2379,8 +2379,8 @@
convert_to_string_ex(path);
 
if (VCWD_REALPATH(Z_STRVAL_PP(path), resolved_path_buff)) {
-#if ZTS
-# if PHP_WIN32
+#ifdef ZTS
+# ifdef PHP_WIN32
if (_access(resolved_path_buff, 0))
RETURN_FALSE;
 # else

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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-07-28 Thread Ilia Alshanetsky
iliaa   Mon Jul 28 10:42:56 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH: Make pclose() respect references.
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.32 php-src/ext/standard/file.c:1.279.2.33
--- php-src/ext/standard/file.c:1.279.2.32  Sun Jul 27 14:46:03 2003
+++ php-src/ext/standard/file.c Mon Jul 28 10:42:56 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.32 2003/07/27 18:46:03 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.33 2003/07/28 14:42:56 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1242,7 +1242,8 @@
 
php_stream_from_zval(stream, arg1);
 
-   RETURN_LONG(php_stream_close(stream));
+   zend_list_delete(stream->rsrc_id);
+   RETURN_LONG(FG(pclose_ret));
 }
 /* }}} */
 



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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-07-24 Thread Wez Furlong
wez Thu Jul 24 11:23:15 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH: Fix for #24629
  
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.30 php-src/ext/standard/file.c:1.279.2.31
--- php-src/ext/standard/file.c:1.279.2.30  Fri Jun 27 12:16:46 2003
+++ php-src/ext/standard/file.c Thu Jul 24 11:23:14 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.30 2003/06/27 16:16:46 pollita Exp $ */
+/* $Id: file.c,v 1.279.2.31 2003/07/24 15:23:14 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -808,8 +808,14 @@
/* If seconds is not set to null, build the timeval, else we wait indefinitely 
*/
if (sec != NULL) {
convert_to_long_ex(&sec);
-   tv.tv_sec = Z_LVAL_P(sec);
-   tv.tv_usec = usec;
+
+   if (usec > 99) {
+   tv.tv_sec = Z_LVAL_P(sec) + (usec / 100);
+   tv.tv_usec = usec % 100;
+   } else {
+   tv.tv_sec = Z_LVAL_P(sec);
+   tv.tv_usec = usec;
+   }
tv_p = &tv;
}
 



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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /main php_streams.h streams.c

2003-06-27 Thread Sara Golemon
pollita Fri Jun 27 12:16:46 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
/php-src/main   php_streams.h streams.c 
  Log:
  Plug the last (hopefully) of the PHP4 context leaks.  This one regarding 
notifier->ptr
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.29 php-src/ext/standard/file.c:1.279.2.30
--- php-src/ext/standard/file.c:1.279.2.29  Thu Jun 26 21:46:30 2003
+++ php-src/ext/standard/file.c Fri Jun 27 12:16:46 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.29 2003/06/27 01:46:30 pollita Exp $ */
+/* $Id: file.c,v 1.279.2.30 2003/06/27 16:16:46 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -875,6 +875,14 @@
zval_ptr_dtor(&retval);
 }
 
+static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
+{
+   if (notifier && notifier->ptr) {
+   zval_ptr_dtor((zval **)&(notifier->ptr));
+   notifier->ptr = NULL;
+   }
+}
+
 static int parse_context_options(php_stream_context *context, zval *options)
 {
HashPosition pos, opos;
@@ -923,6 +931,7 @@
context->notifier->func = user_space_stream_notifier;
context->notifier->ptr = *tmp;
ZVAL_ADDREF(*tmp);
+   context->notifier->dtor = user_space_stream_notifier_dtor;
}
if ((ret = zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), 
(void**)&tmp)) == SUCCESS) {
parse_context_options(context, *tmp);
Index: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.61.2.14 php-src/main/php_streams.h:1.61.2.15
--- php-src/main/php_streams.h:1.61.2.14Fri May 30 21:37:44 2003
+++ php-src/main/php_streams.h  Fri Jun 27 12:16:46 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_streams.h,v 1.61.2.14 2003/05/31 01:37:44 sniper Exp $ */
+/* $Id: php_streams.h,v 1.61.2.15 2003/06/27 16:16:46 pollita Exp $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -96,6 +96,7 @@
 typedef struct _php_stream_wrapper php_stream_wrapper;
 typedef struct _php_stream_context php_stream_context;
 typedef struct _php_stream_filter php_stream_filter;
+typedef struct _php_stream_notifier php_stream_notifier;
 
 /* callback for status notifications */
 typedef void (*php_stream_notification_func)(php_stream_context *context,
@@ -119,12 +120,13 @@
 
 #define PHP_STREAM_NOTIFIER_PROGRESS   1
 
-typedef struct _php_stream_notifier {
+struct _php_stream_notifier {
php_stream_notification_func func;
+   void (*dtor)(php_stream_notifier *notifier);
void *ptr;
int mask;
size_t progress, progress_max; /* position for progress notification */
-} php_stream_notifier;
+};
 
 struct _php_stream_context {
php_stream_notifier *notifier;
Index: php-src/main/streams.c
diff -u php-src/main/streams.c:1.125.2.70 php-src/main/streams.c:1.125.2.71
--- php-src/main/streams.c:1.125.2.70   Thu Jun 26 23:40:55 2003
+++ php-src/main/streams.c  Fri Jun 27 12:16:46 2003
@@ -20,7 +20,7 @@
+--+
  */
 
-/* $Id: streams.c,v 1.125.2.70 2003/06/27 03:40:55 pollita Exp $ */
+/* $Id: streams.c,v 1.125.2.71 2003/06/27 16:16:46 pollita Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -2849,6 +2849,9 @@
 
 PHPAPI void php_stream_notification_free(php_stream_notifier *notifier)
 {
+   if (notifier->dtor) {
+   notifier->dtor(notifier);
+   }
efree(notifier);
 }
 



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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c /main streams.c

2003-06-26 Thread Sara Golemon
pollita Thu Jun 26 21:46:30 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
/php-src/main   streams.c 
  Log:
  MFH: Plug memory leaks when freeing contexts (particularly options)
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.28 php-src/ext/standard/file.c:1.279.2.29
--- php-src/ext/standard/file.c:1.279.2.28  Thu Jun 26 21:32:26 2003
+++ php-src/ext/standard/file.c Thu Jun 26 21:46:30 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.28 2003/06/27 01:32:26 pollita Exp $ */
+/* $Id: file.c,v 1.279.2.29 2003/06/27 01:46:30 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -134,7 +134,12 @@
 
 static ZEND_RSRC_DTOR_FUNC(file_context_dtor)
 {
-   php_stream_context_free((php_stream_context*)rsrc->ptr);
+   php_stream_context *context = (php_stream_context*)rsrc->ptr;
+   if (context->options) {
+   zval_ptr_dtor(&context->options);
+   context->options = NULL;
+   }
+   php_stream_context_free(context);
 }
 
 static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC)
@@ -888,7 +893,6 @@
while (SUCCESS == 
zend_hash_get_current_data_ex(Z_ARRVAL_PP(wval), (void**)&oval, &opos)) {
 
if (HASH_KEY_IS_STRING == 
zend_hash_get_current_key_ex(Z_ARRVAL_PP(wval), &okey, &okey_len, &num_key, 0, &opos)) 
{
-   ZVAL_ADDREF(*oval);
php_stream_context_set_option(context, wkey, 
okey, *oval);
}
zend_hash_move_forward_ex(Z_ARRVAL_PP(wval), &opos);
Index: php-src/main/streams.c
diff -u php-src/main/streams.c:1.125.2.68 php-src/main/streams.c:1.125.2.69
--- php-src/main/streams.c:1.125.2.68   Fri May 30 21:37:44 2003
+++ php-src/main/streams.c  Thu Jun 26 21:46:30 2003
@@ -20,7 +20,7 @@
+--+
  */
 
-/* $Id: streams.c,v 1.125.2.68 2003/05/31 01:37:44 sniper Exp $ */
+/* $Id: streams.c,v 1.125.2.69 2003/06/27 01:46:30 pollita Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -2819,7 +2819,10 @@
 
 PHPAPI void php_stream_context_free(php_stream_context *context)
 {
-   zval_ptr_dtor(&context->options);
+   if (context->options) {
+   zval_ptr_dtor(&context->options);
+   context->options = NULL;
+   }
efree(context);
 }
 



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



[PHP-CVS] cvs: php-src(PHP_4_3) /ext/standard file.c

2003-06-26 Thread Sara Golemon
pollita Thu Jun 26 21:32:26 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/ext/standard   file.c 
  Log:
  MFH streamsfuncs.c r-1.22
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.27 php-src/ext/standard/file.c:1.279.2.28
--- php-src/ext/standard/file.c:1.279.2.27  Thu Jun 19 12:35:29 2003
+++ php-src/ext/standard/file.c Thu Jun 26 21:32:26 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.279.2.27 2003/06/19 16:35:29 iliaa Exp $ */
+/* $Id: file.c,v 1.279.2.28 2003/06/27 01:32:26 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -924,10 +924,6 @@
parse_context_options(context, *tmp);
}
 
-   if (ret != SUCCESS) {
-   php_stream_context_free(context);
-   }
-
return ret;
 }
 
@@ -938,16 +934,20 @@
 {
php_stream_context *context = NULL;
 
-   context = zend_fetch_resource(&contextresource TSRMLS_CC, -1, 
"Stream-Context", NULL, 1, le_stream_context);
+   context = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, NULL, 1, 
php_le_stream_context());
if (context == NULL) {
php_stream *stream;
 
-   php_stream_from_zval_no_verify(stream, &contextresource);
+   stream = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, 
NULL, 2, php_file_le_stream(), php_file_le_pstream);
 
if (stream) {
context = stream->context;
-   if (context == NULL)
+   if (context == NULL) {
context = stream->context = php_stream_context_alloc();
+   /* Register this magical context so that it'll
+  get cleaned up later. PHP5 does this more cleanly */
+   ZEND_REGISTER_RESOURCE(NULL, context, 
php_le_stream_context());
+   }
}
}
 



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