[PHP-CVS] cvs: php-src(PHP_5_3) / README.PARAMETER_PARSING_API /win32/build config.w32 ZendEngine2 Zend.m4 zend_API.c zend_compile.c zend_execute.c zend_execute_API.c zend_operators.c zend_operators

2009-06-04 Thread Matt Wilmas
mattwil Thu Jun  4 18:20:48 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-srcREADME.PARAMETER_PARSING_API 
/ZendEngine2Zend.m4 zend_API.c zend_compile.c zend_execute.c 
zend_execute_API.c zend_operators.c zend_operators.h 
zend_vm_def.h zend_vm_execute.h 
/php-src/win32/buildconfig.w32 
  Log:
  MFH:
  Restored double->long conversion behavior to that of PHP 5.2 (on most 
platforms) and prior:
   * Out-of-range numbers overflow/preserve least significant bits (no 
LONG_MAX/MIN limit)
   * See bug #42868 (presumably-rare platform with different results in 5.2)
   * On 32-bit platforms with 64-bit long type, a zend_long64 cast has been 
added,
  otherwise it's the same as 5.2
   * Use this conversion method everywhere instead of some plain (long) casts
  
  Added 'L' parameter parsing specifier to ensure a LONG_MAX/MIN limit:
   * Essentially what 5.3's new conversion was doing in most cases
   * Functions with "limit" or "length" type params could be updated to use 
this,
  and prevent confusing overflow behavior with huge numbers (*also* in 5.2)
- See bug #47854, for example; or even #42868 again
  
  # Test updates coming
  http://cvs.php.net/viewvc.cgi/php-src/README.PARAMETER_PARSING_API?r1=1.7.6.2.2.6&r2=1.7.6.2.2.7&diff_format=u
Index: php-src/README.PARAMETER_PARSING_API
diff -u php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.6 
php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.7
--- php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.6Mon Nov 24 18:10:36 2008
+++ php-src/README.PARAMETER_PARSING_APIThu Jun  4 18:20:42 2009
@@ -48,6 +48,7 @@
  h  - array (returned as HashTable*)
  H  - array or HASH_OF(object) (returned as HashTable*)
  l  - long (long)
+ L  - long, limits out-of-range numbers to LONG_MAX/LONG_MIN (long)
  o  - object of any type (zval*)
  O  - object of specific type given by class entry (zval*, zend_class_entry)
  r  - resource (zval*)
http://cvs.php.net/viewvc.cgi/ZendEngine2/Zend.m4?r1=1.58.4.4.2.5&r2=1.58.4.4.2.6&diff_format=u
Index: ZendEngine2/Zend.m4
diff -u ZendEngine2/Zend.m4:1.58.4.4.2.5 ZendEngine2/Zend.m4:1.58.4.4.2.6
--- ZendEngine2/Zend.m4:1.58.4.4.2.5Tue Dec  2 16:19:09 2008
+++ ZendEngine2/Zend.m4 Thu Jun  4 18:20:42 2009
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: Zend.m4,v 1.58.4.4.2.5 2008/12/02 16:19:09 cseiler Exp $
+dnl $Id: Zend.m4,v 1.58.4.4.2.6 2009/06/04 18:20:42 mattwil Exp $
 dnl
 dnl This file contains Zend specific autoconf functions.
 dnl
@@ -117,6 +117,38 @@
 ZEND_FP_EXCEPT
 
 ZEND_CHECK_FLOAT_PRECISION
+
+dnl test whether double cast to long preserves least significant bits
+AC_MSG_CHECKING(whether double cast to long preserves least significant bits)
+
+AC_TRY_RUN([
+#include 
+
+int main()
+{
+   if (sizeof(long) == 4) {
+   double d = (double) LONG_MIN * LONG_MIN + 2e9;
+
+   if ((long) d == 2e9 && (long) -d == -2e9) {
+   exit(0);
+   }
+   } else if (sizeof(long) == 8) {
+   double correct = 18e18 - ((double) LONG_MIN * -2); /* Subtract 
ULONG_MAX + 1 */
+
+   if ((long) 18e18 == correct) { /* On 64-bit, only check between 
LONG_MAX and ULONG_MAX */
+   exit(0);
+   }
+   }
+   exit(1);
+}
+], [
+  AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long 
preserves least significant bits])
+  AC_MSG_RESULT(yes)
+], [
+  AC_MSG_RESULT(no)
+], [
+  AC_MSG_RESULT(no)
+])

 ])
 
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.34.2.63&r2=1.296.2.27.2.34.2.64&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.27.2.34.2.63 
ZendEngine2/zend_API.c:1.296.2.27.2.34.2.64
--- ZendEngine2/zend_API.c:1.296.2.27.2.34.2.63 Mon Apr  6 11:10:31 2009
+++ ZendEngine2/zend_API.c  Thu Jun  4 18:20:42 2009
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: zend_API.c,v 1.296.2.27.2.34.2.63 2009/04/06 11:10:31 dmitry Exp $ */
+/* $Id: zend_API.c,v 1.296.2.27.2.34.2.64 2009/06/04 18:20:42 mattwil Exp $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -313,6 +313,7 @@
 
switch (c) {
case 'l':
+   case 'L':
{
long *p = va_arg(*va, long *);
switch (Z_TYPE_PP(arg)) {
@@ -324,14 +325,33 @@
if ((type = 
is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, -1)) == 0) {
return "long";
} else if (type == 
IS_DOUBLE) {
-   *p = (long) d;
+   if (c == 'L') {
+

[PHP-CVS] cvs: php-src(PHP_5_3) / README.PARAMETER_PARSING_API

2008-11-24 Thread Stanislav Malyshev
stasMon Nov 24 18:10:36 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-srcREADME.PARAMETER_PARSING_API 
  Log:
  add object-compatible array modes
  
  
http://cvs.php.net/viewvc.cgi/php-src/README.PARAMETER_PARSING_API?r1=1.7.6.2.2.5&r2=1.7.6.2.2.6&diff_format=u
Index: php-src/README.PARAMETER_PARSING_API
diff -u php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.5 
php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.6
--- php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.5Mon Aug 18 14:34:59 2008
+++ php-src/README.PARAMETER_PARSING_APIMon Nov 24 18:10:36 2008
@@ -39,12 +39,14 @@
  instance of that class.
 
  a  - array (zval*)
+ A  - array or object (zval *)
  b  - boolean (zend_bool)
  C  - class (zend_class_entry*)
  d  - double (double)
  f  - function or array containing php method call info (returned as 
   zend_fcall_info and zend_fcall_info_cache)
  h  - array (returned as HashTable*)
+ H  - array or HASH_OF(object) (returned as HashTable*)
  l  - long (long)
  o  - object of any type (zval*)
  O  - object of specific type given by class entry (zval*, zend_class_entry)



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



[PHP-CVS] cvs: php-src(PHP_5_3) / README.PARAMETER_PARSING_API

2008-08-18 Thread Antony Dovgal
tony2001Mon Aug 18 14:34:59 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-srcREADME.PARAMETER_PARSING_API 
  Log:
  MFH
  
  
http://cvs.php.net/viewvc.cgi/php-src/README.PARAMETER_PARSING_API?r1=1.7.6.2.2.4&r2=1.7.6.2.2.5&diff_format=u
Index: php-src/README.PARAMETER_PARSING_API
diff -u php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.4 
php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.5
--- php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.4Mon Aug 18 13:09:41 2008
+++ php-src/README.PARAMETER_PARSING_APIMon Aug 18 14:34:59 2008
@@ -69,7 +69,7 @@
 Note on 64bit compatibility
 ---
 Please do not forget that int and long are two different things on 64bit 
-OSes (int is 4bit and long is 8bit), so make sure you pass longs to "l" 
+OSes (int is 4 bytes and long is 8 bytes), so make sure you pass longs to "l" 
 and ints to strings length (i.e. for "s" you need to pass char * and int), 
 not the other way round!
 Remember: "l" is the only case when you need to pass long (and that's why 



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



[PHP-CVS] cvs: php-src(PHP_5_3) / README.PARAMETER_PARSING_API

2008-08-18 Thread Antony Dovgal
tony2001Mon Aug 18 13:09:41 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-srcREADME.PARAMETER_PARSING_API 
  Log:
  MFH: add note on 64bit compatibility and mention check_parameters.php
  
  
http://cvs.php.net/viewvc.cgi/php-src/README.PARAMETER_PARSING_API?r1=1.7.6.2.2.3&r2=1.7.6.2.2.4&diff_format=u
Index: php-src/README.PARAMETER_PARSING_API
diff -u php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.3 
php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.4
--- php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.3Tue Nov  6 09:48:24 2007
+++ php-src/README.PARAMETER_PARSING_APIMon Aug 18 13:09:41 2008
@@ -65,6 +65,32 @@
to all specifiers except for 'b', 'l', and 'd'). If NULL is 
passed, the
results pointer is set to NULL as well.
 
+
+Note on 64bit compatibility
+---
+Please do not forget that int and long are two different things on 64bit 
+OSes (int is 4bit and long is 8bit), so make sure you pass longs to "l" 
+and ints to strings length (i.e. for "s" you need to pass char * and int), 
+not the other way round!
+Remember: "l" is the only case when you need to pass long (and that's why 
+it's "l", not "i" btw).
+
+Both mistakes cause memory corruptions and segfaults on 64bit OSes:
+1)
+  char *str;
+  long str_len; /* XXX THIS IS WRONG!! Use int instead. */
+  zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len)
+
+2)
+  int num; /* XXX THIS IS WRONG!! Use long instead. */
+  zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num)
+
+If you're in doubt, use check_parameters.php script to the parameters 
+and their types (it can be found in ./scripts/dev/ directory of PHP sources):
+
+# php ./scripts/dev/check_parameters.php /path/to/your/sources/
+
+
 Examples
 
 /* Gets a long, a string and its length, and a zval */



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



[PHP-CVS] cvs: php-src(PHP_5_3) / README.PARAMETER_PARSING_API

2007-11-06 Thread Jani Taskinen
janiTue Nov  6 09:48:24 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-srcREADME.PARAMETER_PARSING_API 
  Log:
  MFH
  
http://cvs.php.net/viewvc.cgi/php-src/README.PARAMETER_PARSING_API?r1=1.7.6.2.2.2&r2=1.7.6.2.2.3&diff_format=u
Index: php-src/README.PARAMETER_PARSING_API
diff -u php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.2 
php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.3
--- php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.2Fri Nov  2 19:41:10 2007
+++ php-src/README.PARAMETER_PARSING_APITue Nov  6 09:48:24 2007
@@ -52,7 +52,8 @@
  s  - string (with possible null bytes) and its length (char*, int)
  z  - the actual zval (zval*)
  Z  - the actual zval (zval**)
- *  - variable arguments list
+ *  - variable arguments list (0 or more)
+ +  - variable arguments list (1 or more)
 
  The following characters also have a meaning in the specifier string:
 | - indicates that the remaining parameters are optional, they

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



[PHP-CVS] cvs: php-src(PHP_5_3) / README.PARAMETER_PARSING_API

2007-09-28 Thread Johannes Schl
johannesFri Sep 28 22:04:40 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-srcREADME.PARAMETER_PARSING_API 
  Log:
  - MFH: Fix type in example
  
http://cvs.php.net/viewvc.cgi/php-src/README.PARAMETER_PARSING_API?r1=1.7.6.2&r2=1.7.6.2.2.1&diff_format=u
Index: php-src/README.PARAMETER_PARSING_API
diff -u php-src/README.PARAMETER_PARSING_API:1.7.6.2 
php-src/README.PARAMETER_PARSING_API:1.7.6.2.2.1
--- php-src/README.PARAMETER_PARSING_API:1.7.6.2Mon Feb  5 17:57:51 2007
+++ php-src/README.PARAMETER_PARSING_APIFri Sep 28 22:04:39 2007
@@ -70,7 +70,7 @@
 /* Gets an object of class specified by my_ce, and an optional double. */
 zval *obj;
 double d = 0.5;
-zend_class_entry my_ce;
+zend_class_entry *my_ce;
 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|d",
  &obj, my_ce, &d) == FAILURE) {
return;

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