Skip to content

Commit

Permalink
net: sockets: tls: Fix iov_len comparison in sendmsg()
Browse files Browse the repository at this point in the history
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 <robert.lubos@nordicsemi.no>
  • Loading branch information
rlubos authored and aescolar committed Jun 26, 2024
1 parent 9ada52f commit ee451e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion subsys/net/lib/sockets/sockets_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ee451e5

Please sign in to comment.