mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-19 05:10:40 +00:00
api,sockets: Fix signed overflow check
Signed overflow is undefined behaviour in C/C++.
This commit is contained in:
parent
e3a20b3bc2
commit
2e3dcf06d1
@ -1012,7 +1012,7 @@ 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) {
|
if (recvd > SSIZE_MAX - copylen) {
|
||||||
/* overflow */
|
/* overflow */
|
||||||
copylen = (u16_t)(SSIZE_MAX - recvd);
|
copylen = (u16_t)(SSIZE_MAX - recvd);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user