coap_gnutls.c: Fixed NULL pointer dereference

Avoid calling gnutls_transport_get_ptr() on a NULL pointer. The
crash can be reproduced by sending an invalid CA certificate.
This commit is contained in:
Olaf Bergmann committed 2019-02-09 13:31:50 +01:00
1 parent 7b98419dae
commit afb0d954ed
1 file changed
+8 -3
+8 -3
View File
@@ -161,9 +161,14 @@ coap_get_tls_library_version(void) {
static void
coap_gnutls_audit_log_func(gnutls_session_t g_session, const char* text)
{
coap_session_t *c_session =
(coap_session_t *)gnutls_transport_get_ptr(g_session);
coap_log(LOG_WARNING, "** %s: %s", coap_session_str(c_session), text);
if (g_session) {
coap_session_t *c_session =
(coap_session_t *)gnutls_transport_get_ptr(g_session);
coap_log(LOG_WARNING, "** %s: %s",
coap_session_str(c_session), text);
} else {
coap_log(LOG_WARNING, "** (null): %s", text);
}
}
static void