diff options
author | Sean Bright <sean.bright@gmail.com> | 2017-03-22 18:32:37 -0400 |
---|---|---|
committer | Sean Bright <sean.bright@gmail.com> | 2017-03-23 08:57:11 -0600 |
commit | 7657c279b592b40fc6922122c3c3954b118a0ec7 (patch) | |
tree | eeecdd29f2a4e7de33b7eb0e0d89dbf801524caf /res/res_xmpp.c | |
parent | c1ab8ca74cec45730107cca3ed47fc61460365e4 (diff) |
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
Diffstat (limited to 'res/res_xmpp.c')
-rw-r--r-- | res/res_xmpp.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/res/res_xmpp.c b/res/res_xmpp.c index 1aa865cd6..617c401d2 100644 --- a/res/res_xmpp.c +++ b/res/res_xmpp.c @@ -2562,10 +2562,16 @@ static void xmpp_log_hook(void *data, const char *xmpp, size_t size, int incomin 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 |