diff --git a/drivers/modem/simcom-sim7080.c b/drivers/modem/simcom-sim7080.c index dfcfb49f5b9..958b00837cc 100644 --- a/drivers/modem/simcom-sim7080.c +++ b/drivers/modem/simcom-sim7080.c @@ -447,6 +447,7 @@ exit: */ static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags) { + struct modem_socket *sock = obj; ssize_t sent = 0; const char *buf; size_t len; @@ -458,6 +459,17 @@ static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags) return -EAGAIN; } + if (sock->type == SOCK_DGRAM) { + /* + * Current implementation only handles single contiguous fragment at a time, so + * prevent sending multiple datagrams. + */ + if (msghdr_non_empty_iov_count(msg) > 1) { + errno = EMSGSIZE; + return -1; + } + } + for (int i = 0; i < msg->msg_iovlen; i++) { buf = msg->msg_iov[i].iov_base; len = msg->msg_iov[i].iov_len;