php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5775 \0 when exec returns with an empty stdout
Submitted: 2000-07-25 03:26 UTC Modified: 2000-08-01 09:20 UTC
From: iliaa at home dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.0 OS: FreeBSD 3.3 RELEASE/Linux 2.2.16
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: iliaa at home dot com
New email:
PHP Version: OS:

 

 [2000-07-25 03:26 UTC] iliaa at home dot com
PHP seems to consider \0 (NULL chracter) a valid value.
As the result check such as if($val) is true.

Example Code:
<?
$ret_val = exec("ps -p 1 | grep shit");
if( $ret_val ) {
	echo "this shouldn't happen\n";
}
 
echo ord($ret_val)."\n";
echo strlen($ret_val)."\n";
?>

Maybe the type juggling mechanism gets confused?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-25 11:55 UTC] stas@php.net
Well, seems to be a bug, in meaning that when command returns nothing, return value is "\0" and not empty.
 [2000-08-01 09:20 UTC] stas@php.net
Fixed in CVS
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC