1
0
mirror of https://github.com/irssi/irssi.git synced 2024-06-30 06:45:25 +00:00

Merge pull request #1086 from ailin-nemui/define-line-len

increase disconnect buffer and get rid of some magic 510 values
This commit is contained in:
ailin-nemui 2019-08-13 18:29:28 +02:00 committed by GitHub
commit ab8385d2bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 12 deletions

View File

@ -51,7 +51,7 @@ static void sig_disconnect(NET_DISCONNECT_REC *rec)
char buf[512];
int count, ret;
/* check if there's any data waiting in socket. read max. 5kB so
/* check if there's any data waiting in socket. read max. 9kB so
if server just keeps sending us stuff we won't get stuck */
count = 0;
do {
@ -61,7 +61,7 @@ static void sig_disconnect(NET_DISCONNECT_REC *rec)
net_disconnect_remove(rec);
}
count++;
} while (ret == sizeof(buf) && count < 10);
} while (ret == sizeof(buf) && count < 18);
}
static int sig_timeout_disconnect(void)

View File

@ -142,7 +142,7 @@ static void irc_channels_join(IRC_SERVER_REC *server, const char *data,
/* don't try to send too long lines
make sure it's not longer than 510
so 510 - strlen("JOIN ") = 505 */
if (cmdlen < 505)
if (cmdlen < MAX_IRC_MESSAGE_LEN - 5 /* strlen("JOIN ") */)
continue;
}
if (outchans->len > 0) {

View File

@ -55,12 +55,6 @@
#define DEFAULT_CMDS_MAX_AT_ONCE 5
#define DEFAULT_MAX_QUERY_CHANS 1 /* more and more IRC networks are using stupid ircds.. */
/*
* 63 is the maximum hostname length defined by the protocol. 10 is a common
* username limit on many networks. 1 is for the `@'.
*/
#define MAX_USERHOST_LEN (63 + 10 + 1)
void irc_servers_reconnect_init(void);
void irc_servers_reconnect_deinit(void);
@ -208,7 +202,7 @@ static char **split_message(SERVER_REC *server, const char *target,
/* length calculation shamelessly stolen from splitlong_safe.pl */
return split_line(SERVER(server), msg, target,
510 - strlen(":! PRIVMSG :") -
MAX_IRC_MESSAGE_LEN - strlen(":! PRIVMSG :") -
strlen(ircserver->nick) - MAX_USERHOST_LEN -
strlen(target));
}
@ -498,7 +492,7 @@ char **irc_server_split_action(IRC_SERVER_REC *server, const char *target,
g_return_val_if_fail(data != NULL, NULL);
return split_line(SERVER(server), data, target,
510 - strlen(":! PRIVMSG :\001ACTION \001") -
MAX_IRC_MESSAGE_LEN - strlen(":! PRIVMSG :\001ACTION \001") -
strlen(server->nick) - MAX_USERHOST_LEN -
strlen(target));
}

View File

@ -5,6 +5,15 @@
#include <irssi/src/core/servers.h>
#include <irssi/src/irc/core/modes.h>
/*
* 63 is the maximum hostname length defined by the protocol. 10 is a common
* username limit on many networks. 1 is for the `@'.
*/
#define MAX_USERHOST_LEN (63 + 10 + 1)
#define MAX_IRC_MESSAGE_LEN (512 - 2) /* (2 bytes for CR+LF) */
#define MAX_IRC_TAGS_LEN (8191 - 2) /* (2 bytes for `@' and SPACE) */
#define MAX_IRC_USER_TAGS_LEN 4094
#define CAP_LS_VERSION "302"
#define CAP_SASL "sasl"
#define CAP_MULTI_PREFIX "multi-prefix"

View File

@ -131,7 +131,7 @@ static void notifylist_timeout_server(IRC_SERVER_REC *server)
len = strlen(nick);
if (cmd->len+len+1 > 510)
if (cmd->len+len+1 > MAX_IRC_MESSAGE_LEN)
ison_send(server, cmd);
g_string_append_printf(cmd, "%s ", nick);