From 4060d0d0d7ee06ed6dad834dbb12f4381489aec0 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Thu, 29 Jan 2026 19:07:11 +0300 Subject: Simplify client's buffer overflow So I decided to kill a link when there's no IRC message within 512 bytes, because doing so removes code and IMO makes it more clear If peer->recvd == sizeof(peer->buf), then buffer size passed into next read(peer->fd) will be 0, therefore its return value will be 0. Though, this means that link is almost dropped if it sent exactly 512 bytes not containing an \r\n: they can get information, but on next send ircd will close the connection. But this state is unachievable with an IRC client: it either sends a message <= 512 bytes containing an \r\n, or, if one or more bytes longer, well that's already > 512 bytes hence link is still ready to be read and will be kicked after the next poll() --- peer.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/peer.c b/peer.c index 21dba70..3634834 100644 --- a/peer.c +++ b/peer.c @@ -60,14 +60,5 @@ handle(struct Peer *peer) next: move(peer, p - peer->buf + 2); } - if (peer->recvd == sizeof(peer->buf)) - { - /* - * TODO: maybe somehow be more careful with peer data? - * or drop them? - */ - memset(peer->buf, 0, sizeof(peer->buf)); - peer->recvd = 0; - } return 0; } -- cgit 1.4.1