Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.15

Bug #6269 System::which() returns silliness if passed null
Submitted: 2005-12-16 19:58 UTC
From: cconstantine at php dot net Assigned: cellog
Status: Closed Package: PEAR
PHP Version: 4.3.11 OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 29 + 3 = ?

 
 [2005-12-16 19:58 UTC] cconstantine at php dot net
Description: ------------ System::which(null) returns the first element in the envvar PATH. Would be wise to test the arg for is_string() and nonempty, and return early if caller is violating the API. Diff for CV Id: System.php,v 1.51 2005/11/16 03:28:56 cellog Exp --- System.php.orig 2005-12-16 14:55:38.000000000 -0500 +++ System.php.new 2005-12-16 14:56:47.000000000 -0500 @@ -447,6 +447,11 @@ */ function which($program, $fallback = false) { + // enforce API + if (!is_string($program) || '' == $program) { + return $fallback; + } + // avaible since 4.3.0RC2 if (defined('PATH_SEPARATOR')) { $path_delim = PATH_SEPARATOR; Test script: --------------- <?php require 'System.php'; $result = System::which(null, false); if ( false === $result ) { print("got false"); } else { print $result; } ?> Expected result: ---------------- $result should be false. Actual result: -------------- prints "/bin/" (which is the first element in my PATH envvar.)

Comments

 [2006-01-02 06:12 UTC] cellog
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.