瀏覽代碼

Do not fail if known hosts file does not contain valid host key

KnownHosts (implementing HostKeyRepository) in Jsch can return null
which could cause NullPointerException in Stream.of(...)

Change-Id: Iddcf5f34f8c8475a85ca7ae018bbe48d1b3fbbc0
Signed-off-by: Lajos Olah <lajos.olah.jr@gmail.com>
tags/v5.7.0.202003090808-r
Lajos Olah 4 年之前
父節點
當前提交
61ec1455c0
共有 1 個檔案被更改,包括 7 行新增1 行删除
  1. 7
    1
      org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java

+ 7
- 1
org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java 查看文件

@@ -219,7 +219,13 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {

private static void setPreferredKeyTypesOrder(Session session) {
HostKeyRepository hkr = session.getHostKeyRepository();
List<String> known = Stream.of(hkr.getHostKey(hostName(session), null))
HostKey[] hostKeys = hkr.getHostKey(hostName(session), null);

if (hostKeys == null) {
return;
}

List<String> known = Stream.of(hostKeys)
.map(HostKey::getType)
.collect(toList());


Loading…
取消
儲存