Commit 863ff79f by Carlos Martín Nieto

net: copy the option-injection detection from git

This function returns true if the string starts with a `-` as that could be used
to inject options into commands we execute.
parent 4939fa74
......@@ -1152,3 +1152,8 @@ void git_net_url_dispose(git_net_url *url)
git__free(url->username); url->username = NULL;
git__free(url->password); url->password = NULL;
}
int git_net_looks_like_command_line_option(const char *str)
{
return str && str[0] == '-';
}
......@@ -107,4 +107,13 @@ extern bool git_net_url_matches_pattern_list(
/** Disposes the contents of the structure. */
extern void git_net_url_dispose(git_net_url *url);
/**
* Returns true if the string starts with a dash
*
* These could be used to try to trick an executed subcommand like ssh to do
* something other than what we intend.
*/
int git_net_looks_like_command_line_option(const char *str);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment