janus-ssp / php-x509-validate

PHP library for validating X.509 certificates (SSL) using openssl command
13 stars 6 forks source link

Incorrect logical condition inside shell command abstract. #1

Open kamileczek opened 9 years ago

kamileczek commented 9 years ago

Hi,

there is an error in abstract class Janus_Shell_Command_Abstract. The following code:

$output = '';
$errors = '';
while (!feof($pipes[1]) && !feof($pipes[2])) {
    $output .= fgets($pipes[1]);
    $errors .= fgets($pipes[2]);
}

fclose($pipes[1]);
fclose($pipes[2]);

will not read the whole response of evoked command. Because of using logical condition && the above loop will continue reading until one of pipes reach its end. Better solution is to use || condition, in that case the above loop will continue reading until both pipes reach its ends.

Additionally fgets reads line by line from file pointer, so when error output is redirected to stdout (default library configuration) there is no way to read the whole output.

Regards.

tvdijen commented 6 years ago

I've been playing around with this because it made sense at first, but it actually breaks stuff if you replace && with ||...