modem: ublox-sara-r4: do not truncate outgoing datagrams

Do not truncate outgoing datagrams if they do not fit in maximum handled
packet size. Set EMSGSIZE errno and return -1 instead.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This commit is contained in:
Marcin Niestroj 2022-05-24 12:31:20 +02:00 committed by Carles Cufí
parent ae587f8e50
commit b27bf92234

View file

@ -327,6 +327,11 @@ static ssize_t send_socket_data(void *obj,
* the socket in one command
*/
if (buf_len > MDM_MAX_DATA_LENGTH) {
if (sock->type == SOCK_DGRAM) {
errno = EMSGSIZE;
return -1;
}
buf_len = MDM_MAX_DATA_LENGTH;
}