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 <m.niestroj@emb.dev>
diff --git a/drivers/modem/simcom-sim7080.c b/drivers/modem/simcom-sim7080.c
index dfcfb49..958b008 100644
--- a/drivers/modem/simcom-sim7080.c
+++ b/drivers/modem/simcom-sim7080.c
@@ -447,6 +447,7 @@
*/
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 @@
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;