Module: kamailio
Branch: 6.1
Commit: 93bad4a3efcf7c09e55c2dff4c24cf64b0a05876
URL: 
https://github.com/kamailio/kamailio/commit/93bad4a3efcf7c09e55c2dff4c24cf64b0a05876

Author: JiangHai2011 <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-03-04T10:08:51+01:00

tls: check SSL_set_app_data return value and handle the error

(cherry picked from commit 072e948b41d5633bf5d824141460d72307826d0b)

---

Modified: src/modules/tls/tls_server.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/93bad4a3efcf7c09e55c2dff4c24cf64b0a05876.diff
Patch: 
https://github.com/kamailio/kamailio/commit/93bad4a3efcf7c09e55c2dff4c24cf64b0a05876.patch

---

diff --git a/src/modules/tls/tls_server.c b/src/modules/tls/tls_server.c
index 73c75d8ed6f..cf1f9955b10 100644
--- a/src/modules/tls/tls_server.c
+++ b/src/modules/tls/tls_server.c
@@ -376,11 +376,18 @@ static int tls_complete_init(struct tcp_connection *c)
        }
 #endif
 #endif
+       /* link the extra data struct inside ssl connection*/
+       if(SSL_set_app_data(data->ssl, data) == 0) {
+               LM_ERR("failed to set app_data - possible memory issue\n");
+               if(data->ssl)
+                       SSL_free(data->ssl);
+               if(data->rwbio)
+                       BIO_free(data->rwbio);
+               goto error;
+       }
+       /* SSL_set_bio does not allocate memory and has no return value */
        SSL_set_bio(data->ssl, data->rwbio, data->rwbio);
        c->extra_data = data;
-
-       /* link the extra data struct inside ssl connection*/
-       SSL_set_app_data(data->ssl, data);
        return 0;
 
 error:

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to