summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-07-11 17:10:14 +0200
committerHaru <haru@dotalux.com>2013-07-11 19:54:58 +0200
commit8efd1656864cb9e96cd76a5331cf3286e0ca3695 (patch)
tree9fdad43c50007c2c3399d070001723f73f699962 /src
parent0a1c06b267e549877e0617fe19963b5b7c8c937c (diff)
downloadhercules-8efd1656864cb9e96cd76a5331cf3286e0ca3695.tar.gz
hercules-8efd1656864cb9e96cd76a5331cf3286e0ca3695.tar.bz2
hercules-8efd1656864cb9e96cd76a5331cf3286e0ca3695.tar.xz
hercules-8efd1656864cb9e96cd76a5331cf3286e0ca3695.zip
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 <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/map/irc-bot.c9
1 files changed, 3 insertions, 6 deletions
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;
}
}