summaryrefslogtreecommitdiff
path: root/README.PARAMETER_PARSING_API
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2008-08-18 13:09:41 +0000
committerAntony Dovgal <tony2001@php.net>2008-08-18 13:09:41 +0000
commit991ae6e7d3bde939df0abc69654236506d3210a3 (patch)
tree75ea5cd8a4a19eebc813272b673438944dda31f8 /README.PARAMETER_PARSING_API
parente2451b68256d58c37aac0bbc9acf19b9fa4c818d (diff)
downloadphp-git-991ae6e7d3bde939df0abc69654236506d3210a3.tar.gz
MFH: add note on 64bit compatibility and mention check_parameters.php
Diffstat (limited to 'README.PARAMETER_PARSING_API')
-rw-r--r--README.PARAMETER_PARSING_API26
1 files changed, 26 insertions, 0 deletions
diff --git a/README.PARAMETER_PARSING_API b/README.PARAMETER_PARSING_API
index 1551e8e67e..77aa5c12a4 100644
--- a/README.PARAMETER_PARSING_API
+++ b/README.PARAMETER_PARSING_API
@@ -65,6 +65,32 @@ Type specifiers
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 */