From dbe170bd353562c64d1d495e10a4d5ed80dfd233 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 16 Apr 2015 21:55:52 +0200 Subject: fixed a bug in DNS helper code. fixes #1130 --- src/main/java/eu/siacs/conversations/utils/DNSHelper.java | 2 +- src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java index bcb2ca44..42dd1c95 100644 --- a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java @@ -121,7 +121,7 @@ public class DNSHelper { while (p > 0) { p -= s.get(i++).getPriority(); } - i--; + if (i>0) i--; // remove is expensive, but we have only a few entries // anyway SRV srv = s.remove(i); diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 48dc2150..b8e25d4b 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -204,7 +204,7 @@ public class XmppConnection implements Runnable { && "nosrv".equals(result.getString("error", null))) { socket = new Socket(account.getServer().getDomainpart(), 5222); } else { - throw new IOException("timeout in dns"); + throw new IOException("unhandled exception in DNS resolver"); } final OutputStream out = socket.getOutputStream(); tagWriter.setOutputStream(out); -- cgit v1.2.3 From ecd3634c91bb9c6773f8cbb8d9950b6e935f5c6d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 2 May 2015 11:58:19 +0200 Subject: shut up linter. fixed build --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a4062ec3..7b8742c9 100644 --- a/build.gradle +++ b/build.gradle @@ -92,7 +92,7 @@ android { } lintOptions { - disable 'ExtraTranslation', 'MissingTranslation', 'InvalidPackage' + disable 'ExtraTranslation', 'MissingTranslation', 'InvalidPackage', 'MissingQuantity' } subprojects { -- cgit v1.2.3 From 9cc8ba320fac565e6779f129ee4658e43aa36bf6 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 2 May 2015 12:10:56 +0200 Subject: mark account with incompatible server when no sasl mechansim could be found --- .../siacs/conversations/xmpp/XmppConnection.java | 43 ++++++++++++---------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 0b6bb15b..a2b58a14 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -581,26 +581,31 @@ public class XmppConnection implements Runnable { } else if (mechanisms.contains("DIGEST-MD5")) { saslMechanism = new DigestMd5(tagWriter, account, mXmppConnectionService.getRNG()); } - final JSONObject keys = account.getKeys(); - try { - if (keys.has(Account.PINNED_MECHANISM_KEY) && - keys.getInt(Account.PINNED_MECHANISM_KEY) > saslMechanism.getPriority() ) { - Log.e(Config.LOGTAG, "Auth failed. Authentication mechanism " + saslMechanism.getMechanism() + - " has lower priority (" + String.valueOf(saslMechanism.getPriority()) + - ") than pinned priority (" + keys.getInt(Account.PINNED_MECHANISM_KEY) + - "). Possible downgrade attack?"); - disconnect(true); - changeStatus(Account.State.SECURITY_ERROR); - } - } catch (final JSONException e) { - Log.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism"); - } - Log.d(Config.LOGTAG,account.getJid().toString()+": Authenticating with " + saslMechanism.getMechanism()); - auth.setAttribute("mechanism", saslMechanism.getMechanism()); - if (!saslMechanism.getClientFirstMessage().isEmpty()) { - auth.setContent(saslMechanism.getClientFirstMessage()); + if (saslMechanism != null) { + final JSONObject keys = account.getKeys(); + try { + if (keys.has(Account.PINNED_MECHANISM_KEY) && + keys.getInt(Account.PINNED_MECHANISM_KEY) > saslMechanism.getPriority()) { + Log.e(Config.LOGTAG, "Auth failed. Authentication mechanism " + saslMechanism.getMechanism() + + " has lower priority (" + String.valueOf(saslMechanism.getPriority()) + + ") than pinned priority (" + keys.getInt(Account.PINNED_MECHANISM_KEY) + + "). Possible downgrade attack?"); + disconnect(true); + changeStatus(Account.State.SECURITY_ERROR); + } + } catch (final JSONException e) { + Log.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism"); + } + Log.d(Config.LOGTAG, account.getJid().toString() + ": Authenticating with " + saslMechanism.getMechanism()); + auth.setAttribute("mechanism", saslMechanism.getMechanism()); + if (!saslMechanism.getClientFirstMessage().isEmpty()) { + auth.setContent(saslMechanism.getClientFirstMessage()); + } + tagWriter.writeElement(auth); + } else { + disconnect(true); + changeStatus(Account.State.INCOMPATIBLE_SERVER); } - tagWriter.writeElement(auth); } else if (this.streamFeatures.hasChild("sm", "urn:xmpp:sm:" + smVersion) && streamId != null) { -- cgit v1.2.3 From fbf81f59dbc17951faea945cca979312201d00fe Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 2 May 2015 12:12:44 +0200 Subject: version bump to 1.3.1 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 7b8742c9..afc7bb4b 100644 --- a/build.gradle +++ b/build.gradle @@ -44,8 +44,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 21 - versionCode 60 - versionName "1.3.0" + versionCode 61 + versionName "1.3.1" } compileOptions { -- cgit v1.2.3 From 8064832dcaf9098ed7748fbdf3e21f3f6734cd28 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 20 May 2015 08:25:00 +0200 Subject: don't allow user to accidentally send empty messages --- build.gradle | 4 ++-- src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 98b341d5..d572892d 100644 --- a/build.gradle +++ b/build.gradle @@ -44,8 +44,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 21 - versionCode 66 - versionName "1.4.0" + versionCode 67 + versionName "1.4.1" } compileOptions { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 20fc1750..02f664db 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -285,12 +285,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa private Message selectedMessage; private void sendMessage() { - if (this.conversation == null) { + final String body = mEditMessage.getText().toString(); + if (body.length() == 0 || this.conversation == null) { return; } - Message message = new Message(conversation, mEditMessage.getText() - .toString(), conversation.getNextEncryption(activity - .forceEncryption())); + Message message = new Message(conversation, body, conversation.getNextEncryption(activity.forceEncryption())); if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getNextCounterpart() != null) { message.setCounterpart(conversation.getNextCounterpart()); -- cgit v1.2.3