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

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  


 [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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!