abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 98ac772a974f2bae0825f71439ab142de4a6e589
parent f02c3fc3c09ea230778740753bf0d5aab743960f
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue, 17 Feb 2015 22:45:38 +0100

Set packet length to zero on error case

Diffstat:
abduco.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/abduco.c b/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)