mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 07:10:53 +03:00
Check index length.
This commit is contained in:
@@ -200,7 +200,10 @@ public class OpenSSHKnownHosts
|
||||
if (marker != null) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if(split.length < 3) {
|
||||
LOG.error("Error reading entry `{}`", line);
|
||||
return null;
|
||||
}
|
||||
final String hostnames = split[i++];
|
||||
final String sType = split[i++];
|
||||
|
||||
|
||||
@@ -80,4 +80,9 @@ public class OpenSSHKnownHostsTest {
|
||||
assertTrue(kh.verify("69.163.155.180", 22, key));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVerifyIndexError() throws Exception {
|
||||
final OpenSSHKnownHosts v = new OpenSSHKnownHosts(new File("src/test/resources/known_hosts.invalid"));
|
||||
assertTrue(v.entries().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
1
src/test/resources/known_hosts.invalid
Normal file
1
src/test/resources/known_hosts.invalid
Normal file
@@ -0,0 +1 @@
|
||||
M36Lo+Ik5ukNugvvoNFlpnyiHMmtKxt3FpyEfYuryXjNqMNWHn/ARVnpUIl5jRLTB7WBzyLYMG7X5nuoFL9zYqKGtHxChbDunxMVbspw5WXI9VN+qxcLwmITmpEvI9ApyS/Ox2ZyN7zw==
|
||||
Reference in New Issue
Block a user