[Asterisk-code-review] res xmpp: Don't crash when trying to send a message without ... (asterisk[13])
Anonymous Coward
asteriskteam at digium.com
Fri Mar 24 12:04:39 CDT 2017
Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5285 )
Change subject: res_xmpp: Don't crash when trying to send a message without a connection
......................................................................
res_xmpp: Don't crash when trying to send a message without a connection
If we never establish a connection to our Jabber server, iksemel never sets up
its internal transport pointer, so attempting to send a message dereferences a
NULL pointer and causes a crash.
ASTERISK-21855 #close
Reported by: Jeremy Kister
Change-Id: I204a568894e4a53ab929783ecc594a000f04d79c
---
M res/res_xmpp.c
1 file changed, 8 insertions(+), 2 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
diff --git a/res/res_xmpp.c b/res/res_xmpp.c
index 7af5c43..42b3599 100644
--- a/res/res_xmpp.c
+++ b/res/res_xmpp.c
@@ -2564,10 +2564,16 @@
static int xmpp_client_send_raw_message(struct ast_xmpp_client *client, const char *message)
{
int ret;
-#ifdef HAVE_OPENSSL
- int len = strlen(message);
+ if (client->state == XMPP_STATE_DISCONNECTED) {
+ /* iks_send_raw will crash without a connection */
+ return IKS_NET_NOCONN;
+ }
+
+#ifdef HAVE_OPENSSL
if (xmpp_is_secure(client)) {
+ int len = strlen(message);
+
ret = SSL_write(client->ssl_session, message, len);
if (ret) {
/* Log the message here, because iksemel's logHook is
--
To view, visit https://gerrit.asterisk.org/5285
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I204a568894e4a53ab929783ecc594a000f04d79c
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
More information about the asterisk-code-review
mailing list