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)
292
292
try {
293
293
byte [] keyBytes = Base64 .getDecoder ().decode (sKey );
294
294
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 );
297
297
return new BadHostEntry (line );
298
298
}
299
299
} else if (isBits (sType )) {
Original file line number Diff line number Diff line change 23
23
24
24
import java .io .File ;
25
25
import java .io .IOException ;
26
- import java .lang .module .ModuleDescriptor .Opens ;
27
26
import java .nio .charset .StandardCharsets ;
28
27
import java .nio .file .Files ;
29
28
import java .security .PublicKey ;
30
- import java .security .Security ;
31
29
import java .util .Base64 ;
32
30
import java .util .stream .Stream ;
33
31
@@ -110,6 +108,16 @@ public void shouldNotFailOnBadBase64Entry() throws Exception {
110
108
assertTrue (ohk .verify ("host1" , 22 , k ));
111
109
}
112
110
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
+
113
121
@ Test
114
122
public void shouldMarkBadLineAndNotFail () throws Exception {
115
123
File knownHosts = knownHosts (
You can’t perform that action at this time.
0 commit comments