From d26e71971f4cdaebb870236bc7290fd3db7b79d8 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 14 Aug 2016 12:10:32 +0200 Subject: [PATCH] Escape path --- Utils/Git/Git.php | 2 +- Utils/Git/Repository.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Utils/Git/Git.php b/Utils/Git/Git.php index a6412b4e1..81e456dfc 100644 --- a/Utils/Git/Git.php +++ b/Utils/Git/Git.php @@ -49,7 +49,7 @@ class Git public static function test() : bool { $pipes = []; - $resource = proc_open(Git::getBin(), [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes); + $resource = proc_open(escapeshellarg(Git::getBin()), [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes); $stdout = stream_get_contents($pipes[1]); $stderr = stream_get_contents($pipes[2]); diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 4d7d7f6a3..d0ddc68cc 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -177,7 +177,7 @@ class Repository */ private function run(string $cmd) : array { - $cmd = Git::getBin() . ' ' . $cmd; + $cmd = escapeshellarg(Git::getBin()) . ' ' . $cmd; $pipes = []; $desc = [ 1 => ['pipe', 'w'], @@ -203,7 +203,7 @@ class Repository $status = trim(proc_close($resource)); - if ($status) { + if ($status == -1) { throw new \Exception($stderr); }