php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52676 Eval will crash script when function inside returns a string to be eval'ed
Submitted: 2010-08-23 10:24 UTC Modified: 2010-08-24 11:16 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: wolff dot schetula at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.3 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wolff dot schetula at gmail dot com
New email:
PHP Version: OS:

 

 [2010-08-23 10:24 UTC] wolff dot schetula at gmail dot com
Description:
------------
The code below shows the problem. Any return statement inside the function that is supposed to create the code to be evaluated will crash PHP. Not even Apache will send a header anymore. A white page appears.

If the returned string is stored i a variable first it will work fine. The quickest fix is a (string) cast inside the eval function.

eval((string)foo());

Test script:
---------------
function foo() {
    return 'echo time();';
}

eval(foo());


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-24 02:35 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2010-08-24 02:35 UTC] felipe@php.net
Are you using any Zend Extension? I cannot reproduce any crash on 5.2, 5.3, trunk.
 [2010-08-24 10:30 UTC] wolff dot schetula at gmail dot com
xdebug is activated. Without it the script works fine :)
 [2010-08-24 11:16 UTC] aharvey@php.net
-Status: Feedback +Status: Bogus
 [2010-08-24 11:16 UTC] aharvey@php.net
Glad it's working. :)

Not a PHP bug -> closing.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 14:01:31 2025 UTC