You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2019/07/18 11:23:02 UTC
[mina-sshd] 05/05: Fix possible NPE when handling immediate KEX
packet follow-up in case a peer proposal is not yet set
This is an automated email from the ASF dual-hosted git repository.
lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit 141907415b3d0bb38c3b177d30bdcdef90983667
Author: Lyor Goldstein <lg...@apache.org>
AuthorDate: Tue Jul 9 09:14:54 2019 +0300
Fix possible NPE when handling immediate KEX packet follow-up in case a peer proposal is not yet set
---
.../apache/sshd/common/session/helpers/AbstractSession.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index 9c6dc7e..cc5c926 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -488,10 +488,15 @@ public abstract class AbstractSession extends SessionHelper {
*/
protected SimpleImmutableEntry<String, String> comparePreferredKexProposalOption(KexProposalOption option) {
String[] clientPreferences = GenericUtils.split(clientProposal.get(option), ',');
- String clientValue = clientPreferences[0];
+ String clientValue = GenericUtils.isEmpty(clientPreferences) ? null : clientPreferences[0];
String[] serverPreferences = GenericUtils.split(serverProposal.get(option), ',');
- String serverValue = serverPreferences[0];
- return Objects.equals(clientValue, serverValue) ? null : new SimpleImmutableEntry<>(clientValue, serverValue);
+ String serverValue = GenericUtils.isEmpty(serverPreferences) ? null : serverPreferences[0];
+ if (GenericUtils.isEmpty(clientValue) || GenericUtils.isEmpty(serverValue)
+ || (!Objects.equals(clientValue, serverValue))) {
+ return new SimpleImmutableEntry<>(clientValue, serverValue);
+ }
+
+ return null;
}
/**