mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Merge pull request #140 from sebth/master
Make line splitting fail-safe
This commit is contained in:
commit
3d6051a03e
@ -178,23 +178,15 @@ static char **split_message(SERVER_REC *server, const char *target,
|
|||||||
const char *msg)
|
const char *msg)
|
||||||
{
|
{
|
||||||
IRC_SERVER_REC *ircserver = IRC_SERVER(server);
|
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(ircserver != NULL, NULL);
|
||||||
g_return_val_if_fail(target != NULL, NULL);
|
g_return_val_if_fail(target != NULL, NULL);
|
||||||
g_return_val_if_fail(msg != NULL, NULL);
|
g_return_val_if_fail(msg != NULL, NULL);
|
||||||
|
|
||||||
/*
|
/* length calculation shamelessly stolen from splitlong_safe.pl */
|
||||||
* 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 */
|
|
||||||
return split_line(SERVER(server), msg, target,
|
return split_line(SERVER(server), msg, target,
|
||||||
510 - strlen(":! PRIVMSG :") -
|
510 - strlen(":! PRIVMSG :") -
|
||||||
strlen(ircserver->nick) - userhostlen -
|
strlen(ircserver->nick) - MAX_USERHOST_LEN -
|
||||||
strlen(target));
|
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,
|
char **irc_server_split_action(IRC_SERVER_REC *server, const char *target,
|
||||||
const char *data)
|
const char *data)
|
||||||
{
|
{
|
||||||
int userhostlen = MAX_USERHOST_LEN;
|
|
||||||
|
|
||||||
g_return_val_if_fail(server != NULL, NULL);
|
g_return_val_if_fail(server != NULL, NULL);
|
||||||
g_return_val_if_fail(target != NULL, NULL);
|
g_return_val_if_fail(target != NULL, NULL);
|
||||||
g_return_val_if_fail(data != 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,
|
return split_line(SERVER(server), data, target,
|
||||||
510 - strlen(":! PRIVMSG :\001ACTION \001") -
|
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)
|
void irc_server_send_away(IRC_SERVER_REC *server, const char *reason)
|
||||||
|
Loading…
Reference in New Issue
Block a user