Skip to content

Commit

Permalink
Fixed bug #885: missing validation point returned by strchr in xdebug…
Browse files Browse the repository at this point in the history
…_error_cb.
  • Loading branch information
derickr committed Oct 21, 2012
1 parent f0180b5 commit 9405c43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/bug00885.phpt
Original file line number Original file line Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions xdebug_stack.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -622,8 +622,12 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line


/* find first new line */ /* find first new line */
p = strchr(buffer, '\n'); p = strchr(buffer, '\n');
/* find last quote */ if (!p) {
p = ((char *) zend_memrchr(buffer, '\'', p - buffer)) + 1; p = buffer + strlen(buffer);
} else {
/* find last quote */
p = ((char *) zend_memrchr(buffer, '\'', p - buffer)) + 1;
}
/* Create new buffer */ /* Create new buffer */
tmp_buf = calloc(p - buffer + 1, 1); tmp_buf = calloc(p - buffer + 1, 1);
strncpy(tmp_buf, buffer, p - buffer ); strncpy(tmp_buf, buffer, p - buffer );
Expand Down

0 comments on commit 9405c43

Please sign in to comment.