[hackers] [ii] Reduce effective buffer size per channel input. || Christoph Lohmann

From: <git_AT_suckless.org>
Date: Sat, 25 Dec 2021 12:13:01 +0100 (CET)

commit cfb3464c6e64618ff106babb98ccddb258b2fec5
Author: Christoph Lohmann <20h_AT_r-36.net>
AuthorDate: Thu Dec 23 22:11:08 2021 +0100
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sat Dec 25 12:12:54 2021 +0100

    Reduce effective buffer size per channel input.
    
    This will curb the easy way to trigger a too long line sent to the
    server and prevent this error and connection drop.

diff --git a/ii.c b/ii.c
index 1b3bb9e..2d485aa 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -683,7 +683,14 @@ read_line(int fd, char *buf, size_t bufsiz)
 static void
 handle_channels_input(int ircfd, Channel *c)
 {
- char buf[IRC_MSG_MAX];
+ /*
+ * Do not allow to read this fully, since commands will be
+ * prepended. It will result in too long lines sent to the
+ * server.
+ * TODO: Make this depend on the maximum metadata given by the
+ * server at the beginning of the connection.
+ */
+ char buf[IRC_MSG_MAX-64];
 
         if (read_line(c->fdin, buf, sizeof(buf)) == -1) {
                 if (channel_reopen(c) == -1)
Received on Sat Dec 25 2021 - 12:13:01 CET

This archive was generated by hypermail 2.3.0 : Sat Dec 25 2021 - 12:24:32 CET