From 6cbba96963776f7fea07d20bd91138d7ee7d3af5 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 5 Sep 2012 14:14:15 +0100 Subject: [PATCH] fetcher: Fix some edge cases on host key check --- SparkleLib/SparkleFetcherBase.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SparkleLib/SparkleFetcherBase.cs b/SparkleLib/SparkleFetcherBase.cs index fd1716af..5cfa8194 100755 --- a/SparkleLib/SparkleFetcherBase.cs +++ b/SparkleLib/SparkleFetcherBase.cs @@ -262,6 +262,10 @@ namespace SparkleLib { { string host = RemoteUrl.Host; int port = RemoteUrl.Port; + + if (port < 1) + port = 22; + SparkleLogger.LogInfo ("Auth", "Fetching host key for " + host); Process process = new Process () { @@ -269,7 +273,7 @@ namespace SparkleLib { }; process.StartInfo.FileName = "ssh-keyscan"; - process.StartInfo.Arguments = "-t rsa -p " + port.ToString() + " " + host; + process.StartInfo.Arguments = "-t rsa -p " + port + " " + host; process.StartInfo.WorkingDirectory = SparkleConfig.DefaultConfig.TmpPath; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; @@ -282,7 +286,7 @@ namespace SparkleLib { string host_key = process.StandardOutput.ReadToEnd ().Trim (); process.WaitForExit (); - if (process.ExitCode == 0 && host_key != "") + if (process.ExitCode == 0 && !string.IsNullOrEmpty (host_key)) return host_key; else return null;