Permalink
Browse files

Merged pull request #35

  • Loading branch information...
derickr committed Oct 21, 2012
2 parents f0180b5 + 9405c43 commit e3f75575257466402a2460fb5c48580b121f7977
Showing with 14 additions and 2 deletions.
  1. +8 −0 tests/bug00885.phpt
  2. +6 −2 xdebug_stack.c
View
@@ -0,0 +1,8 @@
+--TEST--
+Test for bug #885: missing validation point returned by strchr in xdebug_error_cb.
+--FILE--
+<?php
+throw new Exception("long message ".str_repeat('.', 10240));
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'Exception' with message 'long message ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... in %sbug00885.php on line 2
View
@@ -622,8 +622,12 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line
/* find first new line */
p = strchr(buffer, '\n');
- /* find last quote */
- p = ((char *) zend_memrchr(buffer, '\'', p - buffer)) + 1;
+ if (!p) {
+ p = buffer + strlen(buffer);
+ } else {
+ /* find last quote */
+ p = ((char *) zend_memrchr(buffer, '\'', p - buffer)) + 1;
+ }
/* Create new buffer */
tmp_buf = calloc(p - buffer + 1, 1);
strncpy(tmp_buf, buffer, p - buffer );

0 comments on commit e3f7557

Please sign in to comment.