mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
ssh_exec: escape remote paths properly
When sending paths to the remote server, escape them properly. Escape them with a single quote, followed by the escaped character, followed by another single quote. This prevents misparsing on the remote side and potential command injection.
This commit is contained in:
@@ -189,7 +189,7 @@ static int get_ssh_cmdline(
|
||||
|
||||
if ((error = git_str_puts(&remote_cmd, command)) < 0 ||
|
||||
(error = git_str_puts(&remote_cmd, " '")) < 0 ||
|
||||
(error = git_str_puts(&remote_cmd, url->path)) < 0 ||
|
||||
(error = git_str_puts_escaped(&remote_cmd, url->path, "'!", "'\\", "'")) < 0 ||
|
||||
(error = git_str_puts(&remote_cmd, "'")) < 0 ||
|
||||
(error = git_vector_insert(args, git_str_detach(&remote_cmd))) < 0)
|
||||
goto done;
|
||||
|
||||
Reference in New Issue
Block a user