|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26615 exec crash on long input lines
Submitted: 2003-12-13 12:59 UTC Modified: 2003-12-13 13:52 UTC
From: runekl at opoint dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 5CVS-2003-12-13 (dev) OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: runekl at opoint dot com
New email:
PHP Version: OS:


 [2003-12-13 12:59 UTC] runekl at opoint dot com
If the command ran by exec outputs a line that is 2*EXEC_INPUT_BUF longer than the previous line a segfault may occur.  It is not difficult to see why this happens just by reading the source code.

In exec.c, line 118, reads

if (buflen < (bufl + EXEC_INPUT_BUF)) {

This condition is correct only the first time, e.g when b=buf.  I think the like should be

if (buflen < (bufl + (b - buf) + EXEC_INPUT_BUF)) {

Reproduce code:
$out = array();
$status = -1;
exec('/usr/bin/seq 5000 | tr \'\n\' \' \'', $out, $status);

Expected result:
Numbers from 1 to 5000 separated by blanks on one line.

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-13 13:52 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

Thanks for the "patch"!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC