File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
main/java/net/schmizz/sshj/transport/verification
test/java/com/hierynomus/sshj/transport/verification Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -292,8 +292,8 @@ public KnownHostEntry parseEntry(String line)
292292 try {
293293 byte [] keyBytes = Base64 .getDecoder ().decode (sKey );
294294 key = new Buffer .PlainBuffer (keyBytes ).readPublicKey ();
295- } catch (IOException ioe ) {
296- log .warn ("Error decoding Base64 key bytes" , ioe );
295+ } catch (IOException | IllegalArgumentException exception ) {
296+ log .warn ("Error decoding Base64 key bytes" , exception );
297297 return new BadHostEntry (line );
298298 }
299299 } else if (isBits (sType )) {
Original file line number Diff line number Diff line change 2323
2424import java .io .File ;
2525import java .io .IOException ;
26- import java .lang .module .ModuleDescriptor .Opens ;
2726import java .nio .charset .StandardCharsets ;
2827import java .nio .file .Files ;
2928import java .security .PublicKey ;
30- import java .security .Security ;
3129import java .util .Base64 ;
3230import java .util .stream .Stream ;
3331
@@ -110,6 +108,16 @@ public void shouldNotFailOnBadBase64Entry() throws Exception {
110108 assertTrue (ohk .verify ("host1" , 22 , k ));
111109 }
112110
111+ @ Test
112+ public void shouldNotFailOnMalformedBase64String () throws IOException {
113+ File knownHosts = knownHosts (
114+ "1.1.1.1 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBA/CkqWXSlbdo7jPshvIWT/m3FAdpSIKUx/uTmz87ObpBxXsfF8aMSiwGMKHjqviTV4cG6F7vFf28ll+9CbGsbs=192\n "
115+ );
116+ OpenSSHKnownHosts ohk = new OpenSSHKnownHosts (knownHosts );
117+ assertEquals (1 , ohk .entries ().size ());
118+ assertThat (ohk .entries ().get (0 )).isInstanceOf (OpenSSHKnownHosts .BadHostEntry .class );
119+ }
120+
113121 @ Test
114122 public void shouldMarkBadLineAndNotFail () throws Exception {
115123 File knownHosts = knownHosts (
You can’t perform that action at this time.
0 commit comments