Ask a Question related to PHP Development, Design and Development.
-
Aigner Michael Franz #1
[PHP-DEV] PATCH: error message length limit
--nextPart1439121.yyTOuA2StQ
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8Bit
Hello,
First, I want to apologize in advance if this should be the wrong list for
this. Please just point me to the correct list in this case.
As noted in the documentation of the function trigger_error
([url]http://www.php.net/trigger_error[/url]), an error message is limited to 1024
characters. It gets truncated if it is longer.
In the PHP web application i currently develop, this can sometimes be pretty
annoying, because i use trigger_error to report error messages i get when
executing SQL queries to a custom error handler that mails me all those
errors. This error message sometimes contain SQL statements that are far
longer than 1024 characters. They get truncated, and i can not see the real
reason of the error then.
The patch i attached increases this limit by continually increasing the
buffer that should hold the error message, until the error message does not
fill up the entire buffer any more.
The patch is against 4.3.4RC1, but should still seemlessly apply to the 4.3
branch in CVS.
--nextPart1439121.yyTOuA2StQ
Content-Type: text/x-diff; name="php-4.3.4RC1-errmsg-len.patch"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="php-4.3.4RC1-errmsg-len.patch"
--- php-4.3.4RC1.orig/Zend/zend.c 2003-09-22 06:22:06.000000000 +0200
+++ php-4.3.4RC1/Zend/zend.c 2003-10-02 13:35:38.000000000 +0200
@@ -705,6 +705,7 @@
char *error_filename;
uint error_lineno;
zval *orig_user_error_handler;
+ uint errmsg_buffer_size;
TSRMLS_FETCH();
/* Obtain relevant filename and lineno */
@@ -766,22 +767,31 @@
ALLOC_INIT_ZVAL(z_error_filename);
ALLOC_INIT_ZVAL(z_error_lineno);
ALLOC_INIT_ZVAL(z_context);
- z_error_message->value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE);
+ errmsg_buffer_size = 0;
+ z_error_message->value.str.val = NULL;
+
+ do {
+ errmsg_buffer_size += ZEND_ERROR_BUFFER_SIZE;
+ if (NULL != z_error_message->value.str.val)
+ efree(z_error_message->value.str.val);
+ z_error_message->value.str.val = (char *) emalloc(errmsg_buffer_size);
#ifdef HAVE_VSNPRINTF
- 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);
+ vsnprintf(z_error_message->value.str.val, errmsg_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 strlen is irrelevant. */
+ z_error_message->value.str.val[errmsg_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);
- 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); */
+ strncpy(z_error_message->value.str.val, format, errmsg_buffer_size);
+ z_error_message->value.str.val[errmsg_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
+ } while (z_error_message->value.str.len >= (errmsg_buffer_size - 1));
+
z_error_message->type = IS_STRING;
z_error_type->value.lval = type;
--nextPart1439121.yyTOuA2StQ
Content-Type: text/plain; charset=us-ascii
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
--nextPart1439121.yyTOuA2StQ--
Aigner Michael Franz Guest
-
Limit on maximum String length?
Does anyone know of a Flex limit on String size? I have tests failing on all Strings longer than about 500K. Don't know if this is a limit on... -
Array out of length error message
Ocassionally, when opening a pdf created in Quark 6.5, I get the above error message. I cannot find anything written regarding this message and what... -
Anydata CSV format length limit?
Greetings. I am using Jeff Zucker's Anydata.pm (0.05) with the CSV format for a basic content management system I'm writing. One of the things I'm... -
stored proc 128 length limit
This parameter that is greater than 128 is part of a dynamic SQL statement. How do I get around this limit?? thanks, AJ -
URL length limit ?
Hi ! Here is my problem : I think an url variable could be limited, maybe someone know the maximum length I can use ? (I try to send an html... -
Marcus Börger #2
Re: [PHP-DEV] PATCH: error message length limit
Hello Aigner,
Friday, October 3, 2003, 6:34:13 PM, you wrote:
> Hello,> First, I want to apologize in advance if this should be the wrong list for
> this. Please just point me to the correct list in this case.> As noted in the documentation of the function trigger_error
> ([url]http://www.php.net/trigger_error[/url]), an error message is limited to 1024
> characters. It gets truncated if it is longer.> In the PHP web application i currently develop, this can sometimes be pretty
> annoying, because i use trigger_error to report error messages i get when
> executing SQL queries to a custom error handler that mails me all those
> errors. This error message sometimes contain SQL statements that are far
> longer than 1024 characters. They get truncated, and i can not see the real
> reason of the error then.> The patch i attached increases this limit by continually increasing the
> buffer that should hold the error message, until the error message does not
> fill up the entire buffer any more.This is fixed for HEAD already and i don't think we should backport the> The patch is against 4.3.4RC1, but should still seemlessly apply to the 4.3
> branch in CVS.
solution to the 4.3 tree.
--
Best regards,
Marcus mailto:helly@php.net
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
Marcus Börger Guest



Reply With Quote

