This commit is contained in:
the-djmaze 2026-10-24 16:24:28 +02:00
parent 343ef172d1
commit 870df2d861
3 changed files with 3 additions and 3 deletions

View file

@ -487,7 +487,7 @@ abstract class Base
protected static function findBinary($name) : ?string protected static function findBinary($name) : ?string
{ {
$binary = \function_exists('shell_exec') ? \trim((string) \shell_exec('which $name')) : ''; $binary = \function_exists('shell_exec') ? \trim((string) \shell_exec('which ' . \escapeshellarg($name))) : '';
if ($binary && \RainLoop\Utils::inOpenBasedir($binary) && \is_executable($binary)) { if ($binary && \RainLoop\Utils::inOpenBasedir($binary) && \is_executable($binary)) {
return $binary; return $binary;
} }

View file

@ -50,7 +50,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
// How to use gpgme-json ? // How to use gpgme-json ?
$this->binary = static::findBinary('gpg'); $this->binary = static::findBinary('gpg');
$info = \preg_replace('/\R +/', ' ', `$this->binary --with-colons --list-config`); $info = \preg_replace('/\R +/', ' ', \shell_exec(\escapeshellcmd($this->binary) . ' --with-colons --list-config'));
if (\preg_match('/cfg:version:([0-9]+\\.[0-9]+\\.[0-9]+)/', $info, $match)) { if (\preg_match('/cfg:version:([0-9]+\\.[0-9]+\\.[0-9]+)/', $info, $match)) {
$this->version = $match[1]; $this->version = $match[1];
} }

View file

@ -43,7 +43,7 @@ class SMIME extends Base
// How to use gpgme-json ? // How to use gpgme-json ?
$this->binary = static::findBinary('gpgsm'); $this->binary = static::findBinary('gpgsm');
$info = \preg_replace('/\R +/', ' ', \shell_exec("{$this->binary} --version")); $info = \preg_replace('/\R +/', ' ', \shell_exec(\escapeshellcmd($this->binary) . ' --version') );
if (\preg_match('/gpgsm.+([0-9]+\\.[0-9]+\\.[0-9]+)/', $info, $match)) { if (\preg_match('/gpgsm.+([0-9]+\\.[0-9]+\\.[0-9]+)/', $info, $match)) {
$this->version = $match[1]; $this->version = $match[1];
} }