summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@0x90.dk>2014-10-01 21:55:56 +0200
committerAlexander Færøy <ahf@0x90.dk>2014-10-01 21:55:56 +0200
commit3d6051a03e4d29f67d68c39399f29d9896bdde82 (patch)
tree5c4b759ae099f0e04d1632e6ce60bcc9d9b64a65 /src/irc
parenta2121efed3c51beee3a26ef769f280c88bc551e6 (diff)
parent42a34a78e86c79b75936ec46b5e6cafdaa05b7f5 (diff)
downloadirssi-3d6051a03e4d29f67d68c39399f29d9896bdde82.zip
Merge pull request #140 from sebth/master
Make line splitting fail-safe
Diffstat (limited to 'src/irc')
-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 86f1b0b1..27878989 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)