Skip to content

Commit df5d1f2

Browse files
mniestrojmbolivar-nordic
authored andcommitted
modem: simcom-sim7080: do not send fragmented data as multiple datagrams
Check if there are multiple non-empty data fragments passed to sendmsg() function. If positive, then set EMSGSIZE errno and return -1, as that case is not handled properly with current implementation. Signed-off-by: Marcin Niestroj <[email protected]>
1 parent 032b908 commit df5d1f2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/modem/simcom-sim7080.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ static ssize_t offload_recvfrom(void *obj, void *buf, size_t max_len, int flags,
447447
*/
448448
static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags)
449449
{
450+
struct modem_socket *sock = obj;
450451
ssize_t sent = 0;
451452
const char *buf;
452453
size_t len;
@@ -458,6 +459,17 @@ static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags)
458459
return -EAGAIN;
459460
}
460461

462+
if (sock->type == SOCK_DGRAM) {
463+
/*
464+
* Current implementation only handles single contiguous fragment at a time, so
465+
* prevent sending multiple datagrams.
466+
*/
467+
if (msghdr_non_empty_iov_count(msg) > 1) {
468+
errno = EMSGSIZE;
469+
return -1;
470+
}
471+
}
472+
461473
for (int i = 0; i < msg->msg_iovlen; i++) {
462474
buf = msg->msg_iov[i].iov_base;
463475
len = msg->msg_iov[i].iov_len;

0 commit comments

Comments
 (0)