mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-07-16 09:47:31 +00:00
Try to fix the socket API for sizeof(int) <= 2 by checking INT_MAX at 2 places
This commit is contained in:
parent
b93572dca8
commit
dbc969c139
|
@ -920,6 +920,10 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
|
||||||
} else {
|
} else {
|
||||||
copylen = (u16_t)recv_left;
|
copylen = (u16_t)recv_left;
|
||||||
}
|
}
|
||||||
|
if (recvd + copylen < recvd) {
|
||||||
|
/* int overflow */
|
||||||
|
copylen = INT_MAX - recvd;
|
||||||
|
}
|
||||||
|
|
||||||
/* copy the contents of the received buffer into
|
/* copy the contents of the received buffer into
|
||||||
the supplied memory pointer mem */
|
the supplied memory pointer mem */
|
||||||
|
@ -1487,7 +1491,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > 0xFFFF) {
|
if (size > LWIP_MIN(0xFFFF, INT_MAX)) {
|
||||||
/* cannot fit into one datagram (at least for us) */
|
/* cannot fit into one datagram (at least for us) */
|
||||||
sock_set_errno(sock, EMSGSIZE);
|
sock_set_errno(sock, EMSGSIZE);
|
||||||
done_socket(sock);
|
done_socket(sock);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user