mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-04 12:12:48 +00:00
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
This commit is contained in:
@@ -2564,10 +2564,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)
|
static int xmpp_client_send_raw_message(struct ast_xmpp_client *client, const char *message)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (client->state == XMPP_STATE_DISCONNECTED) {
|
||||||
|
/* iks_send_raw will crash without a connection */
|
||||||
|
return IKS_NET_NOCONN;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
|
if (xmpp_is_secure(client)) {
|
||||||
int len = strlen(message);
|
int len = strlen(message);
|
||||||
|
|
||||||
if (xmpp_is_secure(client)) {
|
|
||||||
ret = SSL_write(client->ssl_session, message, len);
|
ret = SSL_write(client->ssl_session, message, len);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* Log the message here, because iksemel's logHook is
|
/* Log the message here, because iksemel's logHook is
|
||||||
|
Reference in New Issue
Block a user