asterisk/third-party/pjproject/patches/0048-r5576-svn-backport-tls-crash.patch
Alexander Traud 7a46cd7433 pjproject_bundled: Crash on pj_ssl_get_info() while ioqueue_on_read_complete().
When the Asterisk channel driver res_pjsip offers SIP-over-TLS, sometimes, not
reproducible, Asterisk crashed in pj_ssl_sock_get_info() because a NULL pointer
was read. This change avoids this crash.

ASTERISK-26927 #close

Change-Id: I24a6011b44d1426d159742ff4421cf806a52938b
2017-04-07 15:06:11 +02:00

33 lines
1,004 B
Diff

Index: /pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
===================================================================
--- a/pjlib/src/pj/ssl_sock_ossl.c (revision 5564)
+++ b/pjlib/src/pj/ssl_sock_ossl.c (revision 5565)
@@ -145,5 +145,6 @@
SSL_STATE_NULL,
SSL_STATE_HANDSHAKING,
- SSL_STATE_ESTABLISHED
+ SSL_STATE_ESTABLISHED,
+ SSL_STATE_ERROR
};
@@ -1907,4 +1908,8 @@
buf->len += size_;
+ if (status != PJ_SUCCESS) {
+ ssock->ssl_state = SSL_STATE_ERROR;
+ }
+
ret = (*ssock->param.cb.on_data_read)(ssock, buf->data,
buf->len, status,
@@ -2658,5 +2663,9 @@
/* Current cipher */
cipher = SSL_get_current_cipher(ssock->ossl_ssl);
- info->cipher = (SSL_CIPHER_get_id(cipher) & 0x00FFFFFF);
+ if (cipher) {
+ info->cipher = (SSL_CIPHER_get_id(cipher) & 0x00FFFFFF);
+ } else {
+ info->cipher = PJ_TLS_UNKNOWN_CIPHER;
+ }
/* Remote address */