mirror of https://github.com/martanne/abduco
Set packet length to zero on error case
This commit is contained in:
parent
f02c3fc3c0
commit
98ac772a97
4
abduco.c
4
abduco.c
|
|
@ -182,8 +182,10 @@ static bool recv_packet(int socket, Packet *pkt) {
|
|||
ssize_t len = read_all(socket, (char*)pkt, packet_header_size());
|
||||
if (len <= 0 || len != packet_header_size())
|
||||
return false;
|
||||
if (pkt->len > sizeof(pkt->u.msg))
|
||||
if (pkt->len > sizeof(pkt->u.msg)) {
|
||||
pkt->len = 0;
|
||||
return false;
|
||||
}
|
||||
if (pkt->len > 0) {
|
||||
len = read_all(socket, pkt->u.msg, pkt->len);
|
||||
if (len <= 0 || len != pkt->len)
|
||||
|
|
|
|||
Loading…
Reference in New Issue