Errors in eval()'ed code produce status code 500
| Request #43177 | Errors in eval()'ed code produce status code 500 | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2007-11-02 11:41 UTC | Modified: | 2011-04-08 21:15 UTC |
|
||||||||||
| From: | taneli at crasman dot fi | Assigned: | ||||||||||||
| Status: | Closed | Package: | *General Issues | |||||||||||
| PHP Version: | 5.2.4 | OS: | Linux | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2007-11-02 11:41 UTC] taneli at crasman dot fi
Description:
------------
Errors in eval()'ed code produces HTTP status code 500 for the request.
Reproduce code:
---------------
Script:
<?php {
eval("this is not right");
}?>
Result:
# curl -I http://localhost/test.php
HTTP/1.0 500 Internal Server Error
Expected result:
----------------
Since parse errors and such in eval()'ed code don't interrupt the script or make it bail out, I think 200 would be a more approriate code.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2007-11-02 11:43 UTC] taneli at crasman dot fi
Here's a patch for this issue: --- php-5.2.4-vanilla/main/main.c 2007-11-01 15:20:37.000000000 +0200 +++ php-5.2.4/main/main.c 2007-11-01 17:26:45.000000000 +0200 @@ -957,11 +957,15 @@ if (!SG(headers_sent) && SG(sapi_headers).http_response_code == 200 ) { - sapi_header_line ctr = {0}; - - ctr.line = "HTTP/1.0 500 Internal Server Error"; - ctr.line_len = strlen(ctr.line); - sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC); + if (!EG(current_execute_data) || + !EG(current_execute_data)->opline || + EG(current_execute_data)->opline->opcode != ZEND_INCLUDE_OR_EVAL) { + sapi_header_line ctr = {0}; + + ctr.line = "HTTP/1.0 500 Internal Server Error"; + ctr.line_len = strlen(ctr.line); + sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC); + } } /* the parser would return 1 (failure), we can bail out nicely */ if (type != E_PARSE) {[2007-11-05 11:06 UTC] holster at iki dot fi
[2011-04-08 21:15 UTC] jani@php.net
-Package: Feature/Change Request +Package: *General Issues
[2012-06-01 17:40 UTC] truth at proposaltech dot com
[2012-06-01 21:55 UTC] truth at proposaltech dot com
[2013-01-02 05:25 UTC] stas@php.net
-Status: Open +Status: Closed