Disallow SSH host names starting with a dash

This commit is contained in:
Eelco Dolstra 2017-08-11 13:55:41 +02:00
parent 82c4b37c6f
commit e4bd42f98f
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 12 additions and 8 deletions

View file

@ -2,6 +2,17 @@
namespace nix {
SSHMaster::SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress, int logFD)
: host(host)
, keyFile(keyFile)
, useMaster(useMaster)
, compress(compress)
, logFD(logFD)
{
if (host == "" || hasPrefix(host, "-"))
throw Error("invalid SSH host name '%s'", host);
}
void SSHMaster::addCommonSSHOpts(Strings & args)
{
for (auto & i : tokenizeString<Strings>(getEnv("NIX_SSHOPTS")))

View file

@ -28,14 +28,7 @@ private:
public:
SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress, int logFD = -1)
: host(host)
, keyFile(keyFile)
, useMaster(useMaster)
, compress(compress)
, logFD(logFD)
{
}
SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress, int logFD = -1);
struct Connection
{