From 2c0a5e3ceefbbf8642f71e106b7cc901a88cff2a Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 12 Sep 2012 10:39:47 +0000 Subject: [PATCH] Add support for ipv6 addresses as destination PR: bin/150530 Submitted by: andy white Tested by: Olivier Cochard-Labbe MFC after: 1 month --- usr.sbin/syslogd/syslogd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index d1c9fd16e28b..2f42975cbcd9 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1931,6 +1931,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) case '@': { char *tp; + char endkey = ':'; /* * scan forward to see if there is a port defined. * so we can't use strlcpy.. @@ -1939,9 +1940,19 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) tp = f->f_un.f_forw.f_hname; p++; - while (*p && (*p != ':') && (i-- > 0)) { + /* + * an ipv6 address should start with a '[' in that case + * we should scan for a ']' + */ + if (*p == '[') { + p++; + endkey = ']'; + } + while (*p && (*p != endkey) && (i-- > 0)) { *tp++ = *p++; } + if (endkey == ']' && *p == endkey) + p++; *tp = '\0'; } /* See if we copied a domain and have a port */