Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend.c
| From: | Sterling Hughes | Date: | Sun, 04 May 2003 17:01:49 +0000 |
| Subject: | Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend.c | ||
| References: | 1 | Groups: | php.zend-engine.cvs |
| Request: | Send a blank email to php-zend-engine-cvs+get-1184@lists.php.net to get a copy of this message | ||
Why not just use vspprintf?
-Sterling
On Sun, 2003-05-04 at 14:21, Marcus Boerger wrote:
> helly Sun May 4 14:21:33 2003 EDT
>
> Modified files:
> /ZendEngine2 zend.c
> Log:
> Fix bug #23162 user_error() crashs if > 1024 bytes (Marcus, Moriyoshi)
>
> Index: ZendEngine2/zend.c
> diff -u ZendEngine2/zend.c:1.226 ZendEngine2/zend.c:1.227
> --- ZendEngine2/zend.c:1.226 Mon Apr 21 13:01:34 2003
> +++ ZendEngine2/zend.c Sun May 4 14:21:32 2003
> @@ -17,7 +17,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: zend.c,v 1.226 2003/04/21 17:01:34 stas Exp $ */
> +/* $Id: zend.c,v 1.227 2003/05/04 18:21:32 helly Exp $ */
>
> #include "zend.h"
> #include "zend_extensions.h"
> @@ -885,12 +885,16 @@
> z_error_message->value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE);
>
> #ifdef HAVE_VSNPRINTF
> - z_error_message->value.str.len = vsnprintf(z_error_message->value.str.val,
> ZEND_ERROR_BUFFER_SIZE, format, args);
> - if (z_error_message->value.str.len > ZEND_ERROR_BUFFER_SIZE-1) {
> - z_error_message->value.str.len = ZEND_ERROR_BUFFER_SIZE-1;
> - }
> + vsnprintf(z_error_message->value.str.val, ZEND_ERROR_BUFFER_SIZE, format, args);
> + /* this MUST be revisited, but for now handle ALL implementation
> + * out there correct. Since this is inside an error handler the
> + * performance loss by strlne is irrelevant. */
> + z_error_message->value.str.val[ZEND_ERROR_BUFFER_SIZE - 1] = '\0';
> + z_error_message->value.str.len = strlen(z_error_message->value.str.val);
> #else
> - strncpy(z_error_message->value.str.val, format, ZEND_ERROR_BUFFER_SIZE);
> + strncpy(z_error_message->value.str.val, va_arg(format, char *), ZEND_ERROR_BUFFER_SIZE);
> + z_error_message->value.str.val[ZEND_ERROR_BUFFER_SIZE - 1] = '\0';
> + z_error_message->value.str.len = strlen(z_error_message->value.str.val);
> /* This is risky... */
> /* z_error_message->value.str.len = vsprintf(z_error_message->value.str.val, format,
> args); */
> #endif
> @@ -910,7 +914,8 @@
>
> z_context->value.ht = EG(active_symbol_table);
> z_context->type = IS_ARRAY;
> - ZVAL_ADDREF(z_context); /* we don't want this one to be freed */
> + z_context->is_ref = 1;
> + z_context->refcount = 2; /* we don't want this one to be freed */
>
> params = (zval ***) emalloc(sizeof(zval **)*5);
> params[0] = &z_error_type;
--
"Nothing is particularly hard if you divide it into small jobs."
- Henry Ford