From 8efd1656864cb9e96cd76a5331cf3286e0ca3695 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 11 Jul 2013 17:10:14 +0200 Subject: Fixed an issue with long hostnames/nicknames in the IRC Bridge This prevents nickname truncation and other possibly ill side-effects in case the source string for a message is in the form: aNickname!~ident@an.irc.user.with.a.very.long.hostname_________ Signed-off-by: Haru --- src/map/irc-bot.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 0be8074c8..d3782bd9b 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -120,15 +120,12 @@ void irc_parse_source(char *source, char *nick, char *ident, char *host) { for(i = 0; i < len; i++) { if( stage == 0 && source[i] == '!' ) { - memcpy(nick, &source[0], min(i,IRC_NICK_LENGTH)); - nick[i] = '\0'; + safestrncpy(nick, &source[0], min(i + 1, IRC_NICK_LENGTH)); pos = i+1; stage = 1; } else if( stage == 1 && source[i] == '@' ) { - memcpy(ident, &source[pos], min(i - pos,IRC_IDENT_LENGTH)); - ident[i-pos] = '\0'; - memcpy(host, &source[i+1], min(len - i,IRC_HOST_LENGTH)); - host[len] = '\0'; + safestrncpy(ident, &source[pos], min(i - pos + 1, IRC_IDENT_LENGTH)); + safestrncpy(host, &source[i+1], min(len - i, IRC_HOST_LENGTH)); break; } } -- cgit v1.2.3-60-g2f50