From ee451e5cf050285b850fdef8e6afaec666994928 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Mon, 24 Jun 2024 12:26:32 +0200 Subject: [PATCH] net: sockets: tls: Fix iov_len comparison in sendmsg() vec->iov_len is of type size_t, so the comparison was always true. Additionally, doing the memcpy() when iov_len was 0 did not really make sense, so do it only when the actual length is larger than 0. Signed-off-by: Robert Lubos --- subsys/net/lib/sockets/sockets_tls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/lib/sockets/sockets_tls.c b/subsys/net/lib/sockets/sockets_tls.c index 30289426a2f8..c04882d92398 100644 --- a/subsys/net/lib/sockets/sockets_tls.c +++ b/subsys/net/lib/sockets/sockets_tls.c @@ -2457,7 +2457,7 @@ static ssize_t dtls_sendmsg_merge_and_send(struct tls_context *ctx, for (int i = 0; i < msg->msg_iovlen; i++) { struct iovec *vec = msg->msg_iov + i; - if (vec->iov_len >= 0) { + if (vec->iov_len > 0) { if (len + vec->iov_len > sizeof(sendmsg_buf)) { k_mutex_unlock(&sendmsg_lock); errno = EMSGSIZE;