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>
This commit is contained in:
parent
032b90845e
commit
df5d1f220b
1 changed files with 12 additions and 0 deletions
|
@ -447,6 +447,7 @@ exit:
|
||||||
*/
|
*/
|
||||||
static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags)
|
static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags)
|
||||||
{
|
{
|
||||||
|
struct modem_socket *sock = obj;
|
||||||
ssize_t sent = 0;
|
ssize_t sent = 0;
|
||||||
const char *buf;
|
const char *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -458,6 +459,17 @@ static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags)
|
||||||
return -EAGAIN;
|
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++) {
|
for (int i = 0; i < msg->msg_iovlen; i++) {
|
||||||
buf = msg->msg_iov[i].iov_base;
|
buf = msg->msg_iov[i].iov_base;
|
||||||
len = msg->msg_iov[i].iov_len;
|
len = msg->msg_iov[i].iov_len;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue