Module: kamailio
Branch: 6.0
Commit: a44abcbcaecea58d3e913b7e6c41a3e7e4ad0ac1
URL: 
https://github.com/kamailio/kamailio/commit/a44abcbcaecea58d3e913b7e6c41a3e7e4ad0ac1

Author: JiangHai2011 <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-03-05T15:21:56+01:00

tls: check SSL_set_app_data return value and handle the error

(cherry picked from commit 072e948b41d5633bf5d824141460d72307826d0b)
(cherry picked from commit 93bad4a3efcf7c09e55c2dff4c24cf64b0a05876)

---

Modified: src/modules/tls/tls_server.c

---

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

---

diff --git a/src/modules/tls/tls_server.c b/src/modules/tls/tls_server.c
index 3bfea131cf2..1806a3a5c66 100644
--- a/src/modules/tls/tls_server.c
+++ b/src/modules/tls/tls_server.c
@@ -314,11 +314,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