[PHP-DEV] PATCH: error message length limit

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default [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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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
    5. 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...
  3. #2

    Default 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.
    > The patch is against 4.3.4RC1, but should still seemlessly apply to the 4.3
    > branch in CVS.
    This is fixed for HEAD already and i don't think we should backport the
    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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139