gschlossnagle Fri Jun 3 03:31:59 2005 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/soap soap.c
Log:
On architectures that support va_copy (specifically x86_64 linux distros),
if you use va_list args more than once, you can corrupt memory - you
need to use va_copy instead. man va_copy for details.
Also, derefrencing a void * to a long on 64 bit is totally uncool.
http://cvs.php.net/diff.php/php-src/ext/soap/soap.c?r1=1.110.2.38&r2=1.110.2.39&ty=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.110.2.38 php-src/ext/soap/soap.c:1.110.2.39
--- php-src/ext/soap/soap.c:1.110.2.38 Tue May 31 10:35:25 2005
+++ php-src/ext/soap/soap.c Fri Jun 3 03:31:59 2005
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: soap.c,v 1.110.2.38 2005/05/31 14:35:25 dmitry Exp $ */
+/* $Id: soap.c,v 1.110.2.39 2005/06/03 07:31:59 gschlossnagle Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -176,6 +176,21 @@
static void (*old_error_handler)(int, const char *, const uint, const char*,
va_list);
+#ifdef va_copy
+#define call_old_error_handler(error_num, error_filename, error_lineno,
format, args) \
+{ \
+ va_list copy; \
+ va_copy(copy, args); \
+ old_error_handler(error_num, error_filename, error_lineno, format,
copy); \
+ va_end(copy); \
+}
+#else
+#define call_old_error_handler(error_num, error_filename, error_lineno,
format, args) \
+{ \
+ old_error_handler(error_num, error_filename, error_lineno, format,
args); \
+}
+#endif
+
#define PHP_SOAP_SERVER_CLASSNAME "SoapServer"
#define PHP_SOAP_CLIENT_CLASSNAME "SoapClient"
#define PHP_SOAP_VAR_CLASSNAME "SoapVar"
@@ -387,7 +402,7 @@
static void php_soap_init_globals(zend_soap_globals *soap_globals)
{
int i;
- long enc;
+ encodePtr enc;
zend_hash_init(&soap_globals->defEnc, 0, NULL, NULL, 1);
zend_hash_init(&soap_globals->defEncIndex, 0, NULL, NULL, 1);
@@ -395,7 +410,7 @@
i = 0;
do {
- enc = (long)&defaultEncoding[i];
+ enc = &defaultEncoding[i];
/* If has a ns and a str_type then index it */
if (defaultEncoding[i].details.type_str) {
@@ -1853,7 +1868,7 @@
_old_current_execute_data = EG(current_execute_data);
if (!SOAP_GLOBAL(use_soap_error_handler)) {
- old_error_handler(error_num, error_filename, error_lineno,
format, args);
+ call_old_error_handler(error_num, error_filename, error_lineno,
format, args);
return;
}
@@ -1875,12 +1890,18 @@
char buffer[1024];
int buffer_len;
zval outbuf, outbuflen;
+ va_list argcopy;
int old = PG(display_errors);
INIT_ZVAL(outbuf);
INIT_ZVAL(outbuflen);
-
+#ifdef va_copy
+ va_copy(argcopy, args);
+ buffer_len = vsnprintf(buffer, sizeof(buffer)-1,
format, argcopy);
+ va_end(argcopy);
+#else
buffer_len = vsnprintf(buffer, sizeof(buffer)-1,
format, args);
+#endif
buffer[sizeof(buffer)-1]=0;
if (buffer_len > sizeof(buffer) - 1 || buffer_len < 0) {
buffer_len = sizeof(buffer) - 1;
@@ -1898,7 +1919,7 @@
PG(display_errors) = 0;
zend_try {
- old_error_handler(error_num, error_filename,
error_lineno, format, args);
+ call_old_error_handler(error_num,
error_filename, error_lineno, format, args);
} zend_catch {
CG(in_compilation) = _old_in_compilation;
EG(in_execution) = _old_in_execution;
@@ -1907,10 +1928,10 @@
PG(display_errors) = old;
zend_bailout();
} else {
- old_error_handler(error_num, error_filename,
error_lineno, format, args);
+ call_old_error_handler(error_num, error_filename,
error_lineno, format, args);
}
#else
- old_error_handler(error_num, error_filename, error_lineno,
format, args);
+ call_old_error_handler(error_num, error_filename, error_lineno,
format, args);
#endif
} else {
int old = PG(display_errors);
@@ -1954,7 +1975,7 @@
PG(display_errors) = 0;
zend_try {
- old_error_handler(error_num, error_filename,
error_lineno, format, args);
+ call_old_error_handler(error_num, error_filename,
error_lineno, format, args);
} zend_catch {
CG(in_compilation) = _old_in_compilation;
EG(in_execution) = _old_in_execution;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php