From: Marcel Holtmann <marcel@holtmann.org>
To: ell@lists.linux.dev
Cc: andrew.zaborowski@intel.com
Subject: [PATCH 3/3] tls: Ensure callbacks are available before using them
Date: Tue, 3 Jan 2023 15:40:00 +0100 [thread overview]
Message-ID: <20230103144000.641471-3-marcel@holtmann.org> (raw)
The common callbacks for TLS ready, disconnect and transmission of
packets are required to be set for any l_tls object. The app_data
callback is made optional in case implementations want to provide
an out-of-band data path.
---
ell/tls.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ell/tls.c b/ell/tls.c
index 687797f1e466..207f6c3ae40f 100644
--- a/ell/tls.c
+++ b/ell/tls.c
@@ -3357,6 +3357,9 @@ LIB_EXPORT struct l_tls *l_tls_new(bool server,
if (!l_key_is_supported(L_KEY_FEATURE_CRYPTO))
return NULL;
+ if (!tx_handler || !ready_handler || !disconnect_handler)
+ return NULL;
+
tls = l_new(struct l_tls, 1);
tls->server = server;
tls->rx = app_data_handler;
@@ -3561,7 +3564,8 @@ bool tls_handle_message(struct l_tls *tls, const uint8_t *message,
return true;
tls->in_callback = true;
- tls->rx(message, len, tls->user_data);
+ if (tls->rx)
+ tls->rx(message, len, tls->user_data);
tls->in_callback = false;
if (tls->pending_destroy) {
--
2.39.0
reply other threads:[~2023-01-03 14:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230103144000.641471-3-marcel@holtmann.org \
--to=marcel@holtmann.org \
--cc=andrew.zaborowski@intel.com \
--cc=ell@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).