[PATCH] - 64 bit issue with zend_parse_parameters calls
| From: | Dave Hill | Date: | Sat, 01 Mar 2003 19:43:59 +0000 |
| Subject: | [PATCH] - 64 bit issue with zend_parse_parameters calls | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-94710@lists.php.net to get a copy of this message | ||
Hi all, I am back again....
Diff against php4-STABLE-200302241430
(without the last patch I suggested)
Applies to 4.5.x and 5.x as well.
Affects any 64 bit OS.
I ran into another problem after I turned optimization back on. Usually
these are hell to find, but Julien Soula (who I met through the
bug database) had encountered this already.
This time I have a 64 bit issue with zend_parse_parameters().
Luckily the problem is not the implementation, rather the usage.
"s" -> needs a char *, int *
"l" -> needs a long *
Passing the wrong type into this function will have .... unexpected
results... :-) In my case I was getting string lengths with random
values in the upper 32 bits making for strings a bit longer than
in reality.
I did a code inspection (helped by cscope) of the 480 hits,
checking what the types were passed for s & l entries. I did this
regardless of if I actually use the code - it was just easier to
look at them all, but this does mean that I will not be compile
testing all of them.... I have 26 changed files. I hope the
diff will work against 4.5.x and later because that was a lot of
files to inspect :-p
Where a type like size_t or an enum was used, I converted this to
a long. I did this because the function is defined as taking a
long, and in some cases (like enum) you may actually be getting
an int. Even in a case like size_t where you are probablly safe,
I have always found it to be safe then sorry.
Interestingly enough I did find one coding error, in
ext/w32api/w32api.c there are two calls with "s|l" and only
two arguments passed into the function, so heaven help anyone
who tries to pass that optional long :-) I guess it is lucky
that I am using Apache/Unix :-)
Per README.SUBMITTING_PATCH I am trying to copy all
of the extension owners.
Files affected:
./ext/domxml/php_domxml.c
./ext/fdf/fdf.c
./ext/ftp/php_ftp.c
./ext/ldap/ldap.c
./ext/mcrypt/mcrypt.c
./ext/mhash/mhash.c
./ext/pgsql/pgsql.c
./ext/posix/posix.c
./ext/dio/dio.c
./ext/sockets/sockets.c
./ext/standard/exec.c
./ext/standard/file.c
./ext/standard/fsock.c
./ext/standard/head.c
./ext/standard/html.c
./ext/standard/metaphone.c
./ext/standard/string.c
./ext/sysvsem/sysvsem.c
./ext/zlib/zlib.c
./ext/bz2/bz2.c
./ext/openssl/openssl.c
./ext/rpc/com/com.c
./ext/iconv/iconv.c
./ext/mbstring/mbstring.c
./ext/mbstring/php_mbregex.c
./ext/zip/zip.c
./main/output.c