summaryrefslogtreecommitdiff
path: root/src/irc/core
diff options
context:
space:
mode:
authorSebastian Thorarensen <sebth@naju.se>2014-09-01 00:11:47 +0200
committerSebastian Thorarensen <sebth@naju.se>2014-09-01 00:24:17 +0200
commit42a34a78e86c79b75936ec46b5e6cafdaa05b7f5 (patch)
tree1ca8b2f7627e0e967ee53894b5875af8c77bd7ef /src/irc/core
parent503cbeb330331e9ab6cf31af453f6232b10b12e2 (diff)
downloadirssi-42a34a78e86c79b75936ec46b5e6cafdaa05b7f5.zip
Make line splitting fail-safe
The userhost Irssi uses for line splitting can in some cases be wrong, for instance when a proxy is used or when a server cloaks the hostname without telling the client. Now Irssi always assumes the userhost is of maximum length. 10 for username (common value) and 63 for hostname (in RFC 2812).
Diffstat (limited to 'src/irc/core')
-rw-r--r--src/irc/core/irc-servers.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c
index 13784f88..6ff4028e 100644
--- a/src/irc/core/irc-servers.c
+++ b/src/irc/core/irc-servers.c
@@ -178,23 +178,15 @@ static char **split_message(SERVER_REC *server, const char *target,
const char *msg)
{
IRC_SERVER_REC *ircserver = IRC_SERVER(server);
- int userhostlen = MAX_USERHOST_LEN;
g_return_val_if_fail(ircserver != NULL, NULL);
g_return_val_if_fail(target != NULL, NULL);
g_return_val_if_fail(msg != NULL, NULL);
- /*
- * If we have joined a channel, userhost will be set, so we can
- * calculate the exact maximum length.
- */
- if (ircserver->userhost != NULL)
- userhostlen = strlen(ircserver->userhost);
-
- /* length calculation shamelessly stolen from splitlong.pl */
+ /* length calculation shamelessly stolen from splitlong_safe.pl */
return split_line(SERVER(server), msg, target,
510 - strlen(":! PRIVMSG :") -
- strlen(ircserver->nick) - userhostlen -
+ strlen(ircserver->nick) - MAX_USERHOST_LEN -
strlen(target));
}
@@ -458,18 +450,14 @@ void irc_server_send_action(IRC_SERVER_REC *server, const char *target, const ch
char **irc_server_split_action(IRC_SERVER_REC *server, const char *target,
const char *data)
{
- int userhostlen = MAX_USERHOST_LEN;
-
g_return_val_if_fail(server != NULL, NULL);
g_return_val_if_fail(target != NULL, NULL);
g_return_val_if_fail(data != NULL, NULL);
- if (server->userhost != NULL)
- userhostlen = strlen(server->userhost);
-
return split_line(SERVER(server), data, target,
510 - strlen(":! PRIVMSG :\001ACTION \001") -
- strlen(server->nick) - userhostlen - strlen(target));
+ strlen(server->nick) - MAX_USERHOST_LEN -
+ strlen(target));
}
void irc_server_send_away(IRC_SERVER_REC *server, const char *reason)