php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #20663 dealing with error size limits
Submitted: 2002-11-26 17:36 UTC Modified: 2004-07-27 14:55 UTC
From: swbrown at ucsd dot edu Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.2.0 OS: Any
Private report: No CVE-ID: None
 [2002-11-26 17:36 UTC] swbrown at ucsd dot edu
trigger_error silently truncates your error after 1024 chars (ZEND_ERROR_BUFFER_SIZE in the source).  I didn't see this documented anywhere, so I'm reporting it as a documentation problem.  I'd rather it be changed to take unlimited length strings than documented, but documenting it would be a good first step.

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-30 12:43 UTC] helly@php.net
The following fix is against ZE2:

cvs -z3 -q diff zend.c (in directory S:\php4-HEAD\Zend)
Index: zend.c
===================================================================
RCS file: /repository/ZendEngine2/zend.c,v
retrieving revision 1.193
diff -u -r1.193 zend.c
--- zend.c	30 Nov 2002 11:20:25 -0000	1.193
+++ zend.c	30 Nov 2002 16:55:20 -0000
@@ -703,8 +703,6 @@
 }
 
 
-#define ZEND_ERROR_BUFFER_SIZE 1024
-
 ZEND_API void zend_error(int type, const char *format, ...)
 {
 	va_list args;
@@ -775,18 +773,7 @@
 			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);
-
-#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;
-			}
-#else
-			strncpy(z_error_message->value.str.val, format, ZEND_ERROR_BUFFER_SIZE);
-			/* This is risky... */
-			/* z_error_message->value.str.len = vsprintf(z_error_message->value.str.val, format, args); */
-#endif
+			z_error_message->value.str.len = vspprintf(&z_error_message->value.str.val, 0, format, args);
 			z_error_message->type = IS_STRING;
 
 			z_error_type->value.lval = type;


 [2003-01-20 14:29 UTC] pollita@php.net
Helly-

  Are you (or someone else) planning on committing that patch? I see you wrote it against rev 1.193, but zend.c is up to 1.205 and the old code (using ZEND_ERROR_BUFFER_SIZE) is still there.  I'd like to put a note on trigger_error()s doc page, but if it is indeed going to be patched (with PHP 5.0)the note should also say that.

  Although I just noticed you don't have karma for ZE2 either :)  Anyone else intending to apply this patch or something similar?
 [2003-01-20 14:41 UTC] derick@php.net
The attached patch is not valid, cause a) it doesn't work (it keeps limiting at 1024 bytes) b) vspprintf is in PHP space, not Zend and c) it might be a bad idea to have unlimited error lenghts because it might be exploited in someway.

Derick
 [2003-01-20 14:48 UTC] pollita@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Actually there are some problems with that patch (re: Derick/Iliaa).  For the present time trigger_error will continue to only accept 1024 character messages.  Documentation updated to reflect limit.
 [2003-01-21 22:27 UTC] philip@php.net
Reopening (changing topic) until someone figures out and documents:

a) If this limit is affected by the log_errors_max_len directive, which defaults to 1024.
b) If  this directive and/or limit affects $php_errormsg.

Changing summary->dealing with error size limits

Also if the answer is no to either (a) and/or (b), why?
 [2004-07-27 14:55 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"This length is applied to logged errors, displayed errors and also to $php_errormsg."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Aug 15 11:01:29 2024 UTC