Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Buffer capacity check for type UInt64 #454

Merged
merged 1 commit into from
Sep 27, 2018

Conversation

OlivierSalasc
Copy link
Contributor

@OlivierSalasc OlivierSalasc commented Sep 27, 2018

While working with openssh signed certificate of type ssh-rsa-cert-v01@openssh.com , i encountered the following exception :

java.lang.ArrayIndexOutOfBoundsException: 514
	at net.schmizz.sshj.common.Buffer.putUInt64Unchecked(Buffer.java:375)
	at net.schmizz.sshj.common.Buffer.putUInt64(Buffer.java:362)
	at net.schmizz.sshj.common.KeyType$CertUtils.writePubKeyContentsIntoBuffer(KeyType.java:340)
	at net.schmizz.sshj.common.KeyType$7.writePubKeyContentsIntoBuffer(KeyType.java:217)
	at net.schmizz.sshj.common.KeyType.putPubKeyIntoBuffer(KeyType.java:281)
	at net.schmizz.sshj.common.Buffer.putPublicKey(Buffer.java:477)
	at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putPubKey(KeyedAuthMethod.java:51)
	at net.schmizz.sshj.userauth.method.AuthPublickey.buildReq(AuthPublickey.java:62)
	at net.schmizz.sshj.userauth.method.AuthPublickey.buildReq(AuthPublickey.java:81)
	at net.schmizz.sshj.userauth.method.AbstractAuthMethod.request(AbstractAuthMethod.java:68)
	at net.schmizz.sshj.userauth.UserAuthImpl.authenticate(UserAuthImpl.java:72)
	at net.schmizz.sshj.SSHClient.auth(SSHClient.java:225)
	at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:346)
	at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:365)

The cause of the issue is in the class net\schmizz\sshj\common\Buffer. When a 64-bit Uint is put in the buffer, the capacity of the buffer is neither checked or expanded (as it is done for the other types).

I fixed the issue and have added 2 units tests.

@hierynomus hierynomus merged commit 17c368f into hierynomus:master Sep 27, 2018
@hierynomus
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants